Lines Matching refs:csk
145 static inline void csk_hold(struct cnic_sock *csk) in csk_hold() argument
147 atomic_inc(&csk->ref_count); in csk_hold()
150 static inline void csk_put(struct cnic_sock *csk) in csk_put() argument
152 atomic_dec(&csk->ref_count); in csk_put()
251 static int cnic_in_use(struct cnic_sock *csk) in cnic_in_use() argument
253 return test_bit(SK_F_INUSE, &csk->flags); in cnic_in_use()
281 struct cnic_sock *csk) in cnic_send_nlmsg() argument
294 if (csk) { in cnic_send_nlmsg()
300 path_req.handle = (u64) csk->l5_cid; in cnic_send_nlmsg()
301 if (test_bit(SK_F_IPV6, &csk->flags)) { in cnic_send_nlmsg()
302 memcpy(&path_req.dst.v6_addr, &csk->dst_ip[0], in cnic_send_nlmsg()
306 memcpy(&path_req.dst.v4_addr, &csk->dst_ip[0], in cnic_send_nlmsg()
310 path_req.vlan_id = csk->vlan_id; in cnic_send_nlmsg()
311 path_req.pmtu = csk->mtu; in cnic_send_nlmsg()
343 struct cnic_sock *csk; in cnic_iscsi_nl_msg_recv() local
361 csk = &cp->csk_tbl[l5_cid]; in cnic_iscsi_nl_msg_recv()
362 csk_hold(csk); in cnic_iscsi_nl_msg_recv()
363 if (cnic_in_use(csk) && in cnic_iscsi_nl_msg_recv()
364 test_bit(SK_F_CONNECT_START, &csk->flags)) { in cnic_iscsi_nl_msg_recv()
366 memcpy(csk->ha, path_resp->mac_addr, 6); in cnic_iscsi_nl_msg_recv()
367 if (test_bit(SK_F_IPV6, &csk->flags)) in cnic_iscsi_nl_msg_recv()
368 memcpy(&csk->src_ip[0], &path_resp->src.v6_addr, in cnic_iscsi_nl_msg_recv()
371 memcpy(&csk->src_ip[0], &path_resp->src.v4_addr, in cnic_iscsi_nl_msg_recv()
374 if (is_valid_ether_addr(csk->ha)) { in cnic_iscsi_nl_msg_recv()
375 cnic_cm_set_pg(csk); in cnic_iscsi_nl_msg_recv()
376 } else if (!test_bit(SK_F_OFFLD_SCHED, &csk->flags) && in cnic_iscsi_nl_msg_recv()
377 !test_bit(SK_F_OFFLD_COMPLETE, &csk->flags)) { in cnic_iscsi_nl_msg_recv()
379 cnic_cm_upcall(cp, csk, in cnic_iscsi_nl_msg_recv()
381 clear_bit(SK_F_CONNECT_START, &csk->flags); in cnic_iscsi_nl_msg_recv()
384 csk_put(csk); in cnic_iscsi_nl_msg_recv()
393 static int cnic_offld_prep(struct cnic_sock *csk) in cnic_offld_prep() argument
395 if (test_and_set_bit(SK_F_OFFLD_SCHED, &csk->flags)) in cnic_offld_prep()
398 if (!test_bit(SK_F_CONNECT_START, &csk->flags)) { in cnic_offld_prep()
399 clear_bit(SK_F_OFFLD_SCHED, &csk->flags); in cnic_offld_prep()
406 static int cnic_close_prep(struct cnic_sock *csk) in cnic_close_prep() argument
408 clear_bit(SK_F_CONNECT_START, &csk->flags); in cnic_close_prep()
411 if (test_and_clear_bit(SK_F_OFFLD_COMPLETE, &csk->flags)) { in cnic_close_prep()
412 while (test_and_set_bit(SK_F_OFFLD_SCHED, &csk->flags)) in cnic_close_prep()
420 static int cnic_abort_prep(struct cnic_sock *csk) in cnic_abort_prep() argument
422 clear_bit(SK_F_CONNECT_START, &csk->flags); in cnic_abort_prep()
425 while (test_and_set_bit(SK_F_OFFLD_SCHED, &csk->flags)) in cnic_abort_prep()
428 if (test_and_clear_bit(SK_F_OFFLD_COMPLETE, &csk->flags)) { in cnic_abort_prep()
429 csk->state = L4_KCQE_OPCODE_VALUE_RESET_COMP; in cnic_abort_prep()
2012 struct cnic_sock *csk = &cp->csk_tbl[l5_cid]; in cnic_bnx2x_connect() local
2042 conn_addr->remote_addr_0 = csk->ha[0]; in cnic_bnx2x_connect()
2043 conn_addr->remote_addr_1 = csk->ha[1]; in cnic_bnx2x_connect()
2044 conn_addr->remote_addr_2 = csk->ha[2]; in cnic_bnx2x_connect()
2045 conn_addr->remote_addr_3 = csk->ha[3]; in cnic_bnx2x_connect()
2046 conn_addr->remote_addr_4 = csk->ha[4]; in cnic_bnx2x_connect()
2047 conn_addr->remote_addr_5 = csk->ha[5]; in cnic_bnx2x_connect()
2073 XSTORM_ISCSI_LOCAL_VLAN_OFFSET(cp->pfid), csk->vlan_id); in cnic_bnx2x_connect()
3109 static int cnic_cm_offload_pg(struct cnic_sock *csk) in cnic_cm_offload_pg() argument
3111 struct cnic_dev *dev = csk->dev; in cnic_cm_offload_pg()
3115 l4kwqe = (struct l4_kwq_offload_pg *) &csk->kwqe1; in cnic_cm_offload_pg()
3124 l4kwqe->da0 = csk->ha[0]; in cnic_cm_offload_pg()
3125 l4kwqe->da1 = csk->ha[1]; in cnic_cm_offload_pg()
3126 l4kwqe->da2 = csk->ha[2]; in cnic_cm_offload_pg()
3127 l4kwqe->da3 = csk->ha[3]; in cnic_cm_offload_pg()
3128 l4kwqe->da4 = csk->ha[4]; in cnic_cm_offload_pg()
3129 l4kwqe->da5 = csk->ha[5]; in cnic_cm_offload_pg()
3140 l4kwqe->host_opaque = csk->l5_cid; in cnic_cm_offload_pg()
3142 if (csk->vlan_id) { in cnic_cm_offload_pg()
3144 l4kwqe->vlan_tag = csk->vlan_id; in cnic_cm_offload_pg()
3151 static int cnic_cm_update_pg(struct cnic_sock *csk) in cnic_cm_update_pg() argument
3153 struct cnic_dev *dev = csk->dev; in cnic_cm_update_pg()
3157 l4kwqe = (struct l4_kwq_update_pg *) &csk->kwqe1; in cnic_cm_update_pg()
3164 l4kwqe->pg_cid = csk->pg_cid; in cnic_cm_update_pg()
3166 l4kwqe->da0 = csk->ha[0]; in cnic_cm_update_pg()
3167 l4kwqe->da1 = csk->ha[1]; in cnic_cm_update_pg()
3168 l4kwqe->da2 = csk->ha[2]; in cnic_cm_update_pg()
3169 l4kwqe->da3 = csk->ha[3]; in cnic_cm_update_pg()
3170 l4kwqe->da4 = csk->ha[4]; in cnic_cm_update_pg()
3171 l4kwqe->da5 = csk->ha[5]; in cnic_cm_update_pg()
3173 l4kwqe->pg_host_opaque = csk->l5_cid; in cnic_cm_update_pg()
3179 static int cnic_cm_upload_pg(struct cnic_sock *csk) in cnic_cm_upload_pg() argument
3181 struct cnic_dev *dev = csk->dev; in cnic_cm_upload_pg()
3185 l4kwqe = (struct l4_kwq_upload *) &csk->kwqe1; in cnic_cm_upload_pg()
3192 l4kwqe->cid = csk->pg_cid; in cnic_cm_upload_pg()
3197 static int cnic_cm_conn_req(struct cnic_sock *csk) in cnic_cm_conn_req() argument
3199 struct cnic_dev *dev = csk->dev; in cnic_cm_conn_req()
3207 l4kwqe1 = (struct l4_kwq_connect_req1 *) &csk->kwqe1; in cnic_cm_conn_req()
3208 l4kwqe2 = (struct l4_kwq_connect_req2 *) &csk->kwqe2; in cnic_cm_conn_req()
3209 l4kwqe3 = (struct l4_kwq_connect_req3 *) &csk->kwqe3; in cnic_cm_conn_req()
3217 l4kwqe3->ka_timeout = csk->ka_timeout; in cnic_cm_conn_req()
3218 l4kwqe3->ka_interval = csk->ka_interval; in cnic_cm_conn_req()
3219 l4kwqe3->ka_max_probe_count = csk->ka_max_probe_count; in cnic_cm_conn_req()
3220 l4kwqe3->tos = csk->tos; in cnic_cm_conn_req()
3221 l4kwqe3->ttl = csk->ttl; in cnic_cm_conn_req()
3222 l4kwqe3->snd_seq_scale = csk->snd_seq_scale; in cnic_cm_conn_req()
3223 l4kwqe3->pmtu = csk->mtu; in cnic_cm_conn_req()
3224 l4kwqe3->rcv_buf = csk->rcv_buf; in cnic_cm_conn_req()
3225 l4kwqe3->snd_buf = csk->snd_buf; in cnic_cm_conn_req()
3226 l4kwqe3->seed = csk->seed; in cnic_cm_conn_req()
3229 if (test_bit(SK_F_IPV6, &csk->flags)) { in cnic_cm_conn_req()
3239 l4kwqe2->src_ip_v6_2 = be32_to_cpu(csk->src_ip[1]); in cnic_cm_conn_req()
3240 l4kwqe2->src_ip_v6_3 = be32_to_cpu(csk->src_ip[2]); in cnic_cm_conn_req()
3241 l4kwqe2->src_ip_v6_4 = be32_to_cpu(csk->src_ip[3]); in cnic_cm_conn_req()
3242 l4kwqe2->dst_ip_v6_2 = be32_to_cpu(csk->dst_ip[1]); in cnic_cm_conn_req()
3243 l4kwqe2->dst_ip_v6_3 = be32_to_cpu(csk->dst_ip[2]); in cnic_cm_conn_req()
3244 l4kwqe2->dst_ip_v6_4 = be32_to_cpu(csk->dst_ip[3]); in cnic_cm_conn_req()
3257 l4kwqe1->cid = csk->cid; in cnic_cm_conn_req()
3258 l4kwqe1->pg_cid = csk->pg_cid; in cnic_cm_conn_req()
3259 l4kwqe1->src_ip = be32_to_cpu(csk->src_ip[0]); in cnic_cm_conn_req()
3260 l4kwqe1->dst_ip = be32_to_cpu(csk->dst_ip[0]); in cnic_cm_conn_req()
3261 l4kwqe1->src_port = be16_to_cpu(csk->src_port); in cnic_cm_conn_req()
3262 l4kwqe1->dst_port = be16_to_cpu(csk->dst_port); in cnic_cm_conn_req()
3263 if (csk->tcp_flags & SK_TCP_NO_DELAY_ACK) in cnic_cm_conn_req()
3265 if (csk->tcp_flags & SK_TCP_KEEP_ALIVE) in cnic_cm_conn_req()
3267 if (csk->tcp_flags & SK_TCP_NAGLE) in cnic_cm_conn_req()
3269 if (csk->tcp_flags & SK_TCP_TIMESTAMP) in cnic_cm_conn_req()
3271 if (csk->tcp_flags & SK_TCP_SACK) in cnic_cm_conn_req()
3273 if (csk->tcp_flags & SK_TCP_SEG_SCALING) in cnic_cm_conn_req()
3281 static int cnic_cm_close_req(struct cnic_sock *csk) in cnic_cm_close_req() argument
3283 struct cnic_dev *dev = csk->dev; in cnic_cm_close_req()
3287 l4kwqe = (struct l4_kwq_close_req *) &csk->kwqe2; in cnic_cm_close_req()
3293 l4kwqe->cid = csk->cid; in cnic_cm_close_req()
3298 static int cnic_cm_abort_req(struct cnic_sock *csk) in cnic_cm_abort_req() argument
3300 struct cnic_dev *dev = csk->dev; in cnic_cm_abort_req()
3304 l4kwqe = (struct l4_kwq_reset_req *) &csk->kwqe2; in cnic_cm_abort_req()
3310 l4kwqe->cid = csk->cid; in cnic_cm_abort_req()
3316 u32 l5_cid, struct cnic_sock **csk, void *context) in cnic_cm_create() argument
3354 *csk = csk1; in cnic_cm_create()
3358 static void cnic_cm_cleanup(struct cnic_sock *csk) in cnic_cm_cleanup() argument
3360 if (csk->src_port) { in cnic_cm_cleanup()
3361 struct cnic_dev *dev = csk->dev; in cnic_cm_cleanup()
3364 cnic_free_id(&cp->csk_port_tbl, be16_to_cpu(csk->src_port)); in cnic_cm_cleanup()
3365 csk->src_port = 0; in cnic_cm_cleanup()
3369 static void cnic_close_conn(struct cnic_sock *csk) in cnic_close_conn() argument
3371 if (test_bit(SK_F_PG_OFFLD_COMPLETE, &csk->flags)) { in cnic_close_conn()
3372 cnic_cm_upload_pg(csk); in cnic_close_conn()
3373 clear_bit(SK_F_PG_OFFLD_COMPLETE, &csk->flags); in cnic_close_conn()
3375 cnic_cm_cleanup(csk); in cnic_close_conn()
3378 static int cnic_cm_destroy(struct cnic_sock *csk) in cnic_cm_destroy() argument
3380 if (!cnic_in_use(csk)) in cnic_cm_destroy()
3383 csk_hold(csk); in cnic_cm_destroy()
3384 clear_bit(SK_F_INUSE, &csk->flags); in cnic_cm_destroy()
3386 while (atomic_read(&csk->ref_count) != 1) in cnic_cm_destroy()
3388 cnic_cm_cleanup(csk); in cnic_cm_destroy()
3390 csk->flags = 0; in cnic_cm_destroy()
3391 csk_put(csk); in cnic_cm_destroy()
3477 static int cnic_resolve_addr(struct cnic_sock *csk, struct cnic_sockaddr *saddr) in cnic_resolve_addr() argument
3479 struct cnic_dev *dev = csk->dev; in cnic_resolve_addr()
3482 return cnic_send_nlmsg(cp, ISCSI_KEVENT_PATH_REQ, csk); in cnic_resolve_addr()
3485 static int cnic_get_route(struct cnic_sock *csk, struct cnic_sockaddr *saddr) in cnic_get_route() argument
3487 struct cnic_dev *dev = csk->dev; in cnic_get_route()
3504 clear_bit(SK_F_IPV6, &csk->flags); in cnic_get_route()
3507 set_bit(SK_F_IPV6, &csk->flags); in cnic_get_route()
3510 memcpy(&csk->dst_ip[0], &saddr->remote.v6.sin6_addr, in cnic_get_route()
3512 csk->dst_port = saddr->remote.v6.sin6_port; in cnic_get_route()
3518 csk->dst_ip[0] = saddr->remote.v4.sin_addr.s_addr; in cnic_get_route()
3519 csk->dst_port = saddr->remote.v4.sin_port; in cnic_get_route()
3523 csk->vlan_id = 0; in cnic_get_route()
3524 csk->mtu = dev->netdev->mtu; in cnic_get_route()
3528 csk->vlan_id = vlan; in cnic_get_route()
3529 csk->mtu = dst_mtu(dst); in cnic_get_route()
3549 csk->src_port = local_port; in cnic_get_route()
3556 static void cnic_init_csk_state(struct cnic_sock *csk) in cnic_init_csk_state() argument
3558 csk->state = 0; in cnic_init_csk_state()
3559 clear_bit(SK_F_OFFLD_SCHED, &csk->flags); in cnic_init_csk_state()
3560 clear_bit(SK_F_CLOSING, &csk->flags); in cnic_init_csk_state()
3563 static int cnic_cm_connect(struct cnic_sock *csk, struct cnic_sockaddr *saddr) in cnic_cm_connect() argument
3567 if (!cnic_in_use(csk)) in cnic_cm_connect()
3570 if (test_and_set_bit(SK_F_CONNECT_START, &csk->flags)) in cnic_cm_connect()
3573 cnic_init_csk_state(csk); in cnic_cm_connect()
3575 err = cnic_get_route(csk, saddr); in cnic_cm_connect()
3579 err = cnic_resolve_addr(csk, saddr); in cnic_cm_connect()
3584 clear_bit(SK_F_CONNECT_START, &csk->flags); in cnic_cm_connect()
3588 static int cnic_cm_abort(struct cnic_sock *csk) in cnic_cm_abort() argument
3590 struct cnic_local *cp = csk->dev->cnic_priv; in cnic_cm_abort()
3593 if (!cnic_in_use(csk)) in cnic_cm_abort()
3596 if (cnic_abort_prep(csk)) in cnic_cm_abort()
3597 return cnic_cm_abort_req(csk); in cnic_cm_abort()
3603 cp->close_conn(csk, opcode); in cnic_cm_abort()
3604 if (csk->state != opcode) in cnic_cm_abort()
3610 static int cnic_cm_close(struct cnic_sock *csk) in cnic_cm_close() argument
3612 if (!cnic_in_use(csk)) in cnic_cm_close()
3615 if (cnic_close_prep(csk)) { in cnic_cm_close()
3616 csk->state = L4_KCQE_OPCODE_VALUE_CLOSE_COMP; in cnic_cm_close()
3617 return cnic_cm_close_req(csk); in cnic_cm_close()
3624 static void cnic_cm_upcall(struct cnic_local *cp, struct cnic_sock *csk, in cnic_cm_upcall() argument
3628 int ulp_type = csk->ulp_type; in cnic_cm_upcall()
3634 ulp_ops->cm_connect_complete(csk); in cnic_cm_upcall()
3636 ulp_ops->cm_close_complete(csk); in cnic_cm_upcall()
3638 ulp_ops->cm_remote_abort(csk); in cnic_cm_upcall()
3640 ulp_ops->cm_abort_complete(csk); in cnic_cm_upcall()
3642 ulp_ops->cm_remote_close(csk); in cnic_cm_upcall()
3647 static int cnic_cm_set_pg(struct cnic_sock *csk) in cnic_cm_set_pg() argument
3649 if (cnic_offld_prep(csk)) { in cnic_cm_set_pg()
3650 if (test_bit(SK_F_PG_OFFLD_COMPLETE, &csk->flags)) in cnic_cm_set_pg()
3651 cnic_cm_update_pg(csk); in cnic_cm_set_pg()
3653 cnic_cm_offload_pg(csk); in cnic_cm_set_pg()
3663 struct cnic_sock *csk = &cp->csk_tbl[l5_cid]; in cnic_cm_process_offld_pg() local
3665 csk_hold(csk); in cnic_cm_process_offld_pg()
3666 if (!cnic_in_use(csk)) in cnic_cm_process_offld_pg()
3670 clear_bit(SK_F_OFFLD_SCHED, &csk->flags); in cnic_cm_process_offld_pg()
3675 clear_bit(SK_F_OFFLD_SCHED, &csk->flags); in cnic_cm_process_offld_pg()
3676 cnic_cm_upcall(cp, csk, in cnic_cm_process_offld_pg()
3681 csk->pg_cid = kcqe->pg_cid; in cnic_cm_process_offld_pg()
3682 set_bit(SK_F_PG_OFFLD_COMPLETE, &csk->flags); in cnic_cm_process_offld_pg()
3683 cnic_cm_conn_req(csk); in cnic_cm_process_offld_pg()
3686 csk_put(csk); in cnic_cm_process_offld_pg()
3707 struct cnic_sock *csk; in cnic_cm_process_kcqe() local
3725 csk = &cp->csk_tbl[l5_cid]; in cnic_cm_process_kcqe()
3726 csk_hold(csk); in cnic_cm_process_kcqe()
3728 if (!cnic_in_use(csk)) { in cnic_cm_process_kcqe()
3729 csk_put(csk); in cnic_cm_process_kcqe()
3736 clear_bit(SK_F_OFFLD_SCHED, &csk->flags); in cnic_cm_process_kcqe()
3737 cnic_cm_upcall(cp, csk, in cnic_cm_process_kcqe()
3743 set_bit(SK_F_OFFLD_COMPLETE, &csk->flags); in cnic_cm_process_kcqe()
3746 clear_bit(SK_F_OFFLD_SCHED, &csk->flags); in cnic_cm_process_kcqe()
3747 cnic_cm_upcall(cp, csk, opcode); in cnic_cm_process_kcqe()
3755 cp->close_conn(csk, opcode); in cnic_cm_process_kcqe()
3759 cnic_cm_upcall(cp, csk, opcode); in cnic_cm_process_kcqe()
3762 csk_put(csk); in cnic_cm_process_kcqe()
3804 static int cnic_ready_to_close(struct cnic_sock *csk, u32 opcode) in cnic_ready_to_close() argument
3806 if (test_and_clear_bit(SK_F_OFFLD_COMPLETE, &csk->flags)) { in cnic_ready_to_close()
3809 csk->state = opcode; in cnic_ready_to_close()
3817 if (opcode == csk->state || csk->state == 0 || in cnic_ready_to_close()
3818 csk->state == L4_KCQE_OPCODE_VALUE_CLOSE_COMP) { in cnic_ready_to_close()
3819 if (!test_and_set_bit(SK_F_CLOSING, &csk->flags)) { in cnic_ready_to_close()
3820 if (csk->state == 0) in cnic_ready_to_close()
3821 csk->state = opcode; in cnic_ready_to_close()
3828 static void cnic_close_bnx2_conn(struct cnic_sock *csk, u32 opcode) in cnic_close_bnx2_conn() argument
3830 struct cnic_dev *dev = csk->dev; in cnic_close_bnx2_conn()
3834 cnic_cm_upcall(cp, csk, opcode); in cnic_close_bnx2_conn()
3838 clear_bit(SK_F_CONNECT_START, &csk->flags); in cnic_close_bnx2_conn()
3839 cnic_close_conn(csk); in cnic_close_bnx2_conn()
3840 csk->state = opcode; in cnic_close_bnx2_conn()
3841 cnic_cm_upcall(cp, csk, opcode); in cnic_close_bnx2_conn()
3857 static void cnic_close_bnx2x_conn(struct cnic_sock *csk, u32 opcode) in cnic_close_bnx2x_conn() argument
3859 struct cnic_dev *dev = csk->dev; in cnic_close_bnx2x_conn()
3861 struct cnic_context *ctx = &cp->ctx_tbl[csk->l5_cid]; in cnic_close_bnx2x_conn()
3870 if (cnic_ready_to_close(csk, opcode)) { in cnic_close_bnx2x_conn()
3871 if (test_bit(SK_F_PG_OFFLD_COMPLETE, &csk->flags)) in cnic_close_bnx2x_conn()
3887 cnic_submit_kwqe_16(dev, cmd, csk->cid, ISCSI_CONNECTION_TYPE, in cnic_close_bnx2x_conn()
3891 cnic_close_conn(csk); in cnic_close_bnx2x_conn()
3892 cnic_cm_upcall(cp, csk, csk->state); in cnic_close_bnx2x_conn()
4041 struct cnic_sock *csk = &cp->csk_tbl[i]; in cnic_cm_shutdown() local
4043 clear_bit(SK_F_INUSE, &csk->flags); in cnic_cm_shutdown()
4044 cnic_cm_cleanup(csk); in cnic_cm_shutdown()