Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cnic: Improve ->iscsi_nl_msg_send()

1. Change first parameter from cnic_dev to ulp_handle which is the hba
pointer. All other similar upcalls are using hba pointer. The callee
can then directly reference the hba without conversion.

2. Change return value from void to int so that an error code can be
passed back. This allows the operation to be retried.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Michael Chan and committed by
David S. Miller
939b82e5 8adc9240

+25 -12
+16 -5
drivers/net/cnic.c
··· 279 279 u32 msg_type = ISCSI_KEVENT_IF_DOWN; 280 280 struct cnic_ulp_ops *ulp_ops; 281 281 struct cnic_uio_dev *udev = cp->udev; 282 + int rc = 0, retry = 0; 282 283 283 284 if (!udev || udev->uio_dev == -1) 284 285 return -ENODEV; ··· 304 303 path_req.pmtu = csk->mtu; 305 304 } 306 305 307 - rcu_read_lock(); 308 - ulp_ops = rcu_dereference(cnic_ulp_tbl[CNIC_ULP_ISCSI]); 309 - if (ulp_ops) 310 - ulp_ops->iscsi_nl_send_msg(cp->dev, msg_type, buf, len); 311 - rcu_read_unlock(); 306 + while (retry < 3) { 307 + rc = 0; 308 + rcu_read_lock(); 309 + ulp_ops = rcu_dereference(cnic_ulp_tbl[CNIC_ULP_ISCSI]); 310 + if (ulp_ops) 311 + rc = ulp_ops->iscsi_nl_send_msg( 312 + cp->ulp_handle[CNIC_ULP_ISCSI], 313 + msg_type, buf, len); 314 + rcu_read_unlock(); 315 + if (rc == 0 || msg_type != ISCSI_KEVENT_PATH_REQ) 316 + break; 317 + 318 + msleep(100); 319 + retry++; 320 + } 312 321 return 0; 313 322 } 314 323
+1 -1
drivers/net/cnic_if.h
··· 301 301 void (*cm_abort_complete)(struct cnic_sock *); 302 302 void (*cm_remote_close)(struct cnic_sock *); 303 303 void (*cm_remote_abort)(struct cnic_sock *); 304 - void (*iscsi_nl_send_msg)(struct cnic_dev *dev, u32 msg_type, 304 + int (*iscsi_nl_send_msg)(void *ulp_ctx, u32 msg_type, 305 305 char *data, u16 data_size); 306 306 struct module *owner; 307 307 atomic_t ref_count;
+8 -6
drivers/scsi/bnx2i/bnx2i_hwi.c
··· 2346 2346 } 2347 2347 2348 2348 2349 - static void bnx2i_send_nl_mesg(struct cnic_dev *dev, u32 msg_type, 2349 + static int bnx2i_send_nl_mesg(void *context, u32 msg_type, 2350 2350 char *buf, u16 buflen) 2351 2351 { 2352 - struct bnx2i_hba *hba; 2352 + struct bnx2i_hba *hba = context; 2353 + int rc; 2353 2354 2354 - hba = bnx2i_find_hba_for_cnic(dev); 2355 2355 if (!hba) 2356 - return; 2356 + return -ENODEV; 2357 2357 2358 - if (iscsi_offload_mesg(hba->shost, &bnx2i_iscsi_transport, 2359 - msg_type, buf, buflen)) 2358 + rc = iscsi_offload_mesg(hba->shost, &bnx2i_iscsi_transport, 2359 + msg_type, buf, buflen); 2360 + if (rc) 2360 2361 printk(KERN_ALERT "bnx2i: private nl message send error\n"); 2361 2362 2363 + return rc; 2362 2364 } 2363 2365 2364 2366