cnic: Fix interrupt logic
Subsystems (2)
PATCH 1/5 cnic: Fix interrupt logic
We need to keep looping until cnic_get_kcqes() returns 0. cnic_get_kcqes() returns a maximum of 64 entries. If there are more entries in the queue and we don't loop back, the remaining entries may not be serviced for a long time.
--- drivers/net/cnic.c | 13 ++++--------- 1 files changed, 4 insertions(+), 9 deletions(-)
drivers/net/cnic.c +4 -9
@@ -2778,13 +2778,10 @@ static u32 cnic_service_bnx2_queues(struct cnic_dev *dev)/* Tell compiler that status_blk fields can change. */ barrier (); -if (status_idx != *cp->kcq1.status_idx_ptr) { - status_idx = (u16) *cp->kcq1.status_idx_ptr; -/* status block index must be read first */ -rmb (); - cp->kwq_con_idx = *cp->kwq_con_idx_ptr; - }else -break ; + status_idx = (u16) *cp->kcq1.status_idx_ptr; +/* status block index must be read first */ +rmb (); + cp->kwq_con_idx = *cp->kwq_con_idx_ptr; }CNIC_WR16 (dev, cp->kcq1.io_addr, cp->kcq1.sw_prod_idx);
@@ -2908,8 +2905,6 @@ static u32 cnic_service_bnx2x_kcq(struct cnic_dev *dev, struct kcq_info *info)/* Tell compiler that sblk fields can change. */ barrier (); -if (last_status == *info->status_idx_ptr) -break ; last_status = *info->status_idx_ptr;/* status block index must be read before reading the KCQ */
Signature · 1 line
1.6.4.GIT
PATCH 2/5 cnic: Fix race conditions with firmware
During iSCSI connection terminations, if the target is also terminating at about the same time, the firmware may not complete the driver's request to close or reset the connection. This is fixed by handling other events (instead of the expected completion event) as an indication that the driver's request has been rejected.
--- drivers/net/cnic.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-)
drivers/net/cnic.c +11 -3
@@ -3767,7 +3767,13 @@ static void cnic_cm_process_kcqe(struct cnic_dev *dev, struct kcqe *kcqe)break ;case L4_KCQE_OPCODE_VALUE_CLOSE_RECEIVED : -cnic_cm_upcall (cp, csk, opcode); +/* after we already sent CLOSE_REQ */ +if (test_bit (CNIC_F_BNX2X_CLASS , &dev->flags) && + !test_bit (SK_F_OFFLD_COMPLETE , &csk->flags) && + csk->state ==L4_KCQE_OPCODE_VALUE_CLOSE_COMP ) + cp->close_conn (csk,L4_KCQE_OPCODE_VALUE_RESET_COMP ); +else +cnic_cm_upcall (cp, csk, opcode);break ; }csk_put (csk);
@@ -3821,12 +3827,14 @@ static int cnic_ready_to_close(struct cnic_sock *csk, u32 opcode) }/* 1. If event opcode matches the expected event in csk->state -* 2. If the expected event is CLOSE_COMP, we accept any event +* 2. If the expected event is CLOSE_COMP or RESET_COMP, we accept any +* event * 3. If the expected event is 0, meaning the connection was never * never established, we accept the opcode from cm_abort. */ if (opcode == csk->state || csk->state ==0 || - csk->state ==L4_KCQE_OPCODE_VALUE_CLOSE_COMP ) { + csk->state ==L4_KCQE_OPCODE_VALUE_CLOSE_COMP || + csk->state ==L4_KCQE_OPCODE_VALUE_RESET_COMP ) {if (!test_and_set_bit (SK_F_CLOSING , &csk->flags)) {if (csk->state ==0 ) csk->state = opcode;
Signature · 1 line
1.6.4.GIT
PATCH 3/5 cnic: Randomize initial TCP port for iSCSI connections
From: Eddie Wai <[email protected]>
This reduces the likelihood of port re-use when re-loading the driver.
--- drivers/net/cnic.c | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-)
drivers/net/cnic.c +9 -5
@@ -605,11 +605,12 @@ static int cnic_unregister_device(struct cnic_dev *dev, int ulp_type) }EXPORT_SYMBOL (cnic_unregister_driver); -static int cnic_init_id_tbl (struct cnic_id_tbl *id_tbl,u32 size,u32 start_id) +static int cnic_init_id_tbl (struct cnic_id_tbl *id_tbl,u32 size,u32 start_id, +u32 next) { id_tbl->start = start_id; id_tbl->max = size; - id_tbl->next =0 ; + id_tbl->next = next;spin_lock_init (&id_tbl->lock); id_tbl->table =kzalloc (DIV_ROUND_UP (size,32 ) *4 ,GFP_KERNEL );if (!id_tbl->table)
@@ -3804,14 +3805,17 @@ static void cnic_cm_free_mem(struct cnic_dev *dev)static int cnic_cm_alloc_mem (struct cnic_dev *dev) {struct cnic_local *cp = dev->cnic_priv; +u32 port_id; cp->csk_tbl =kzalloc (sizeof (struct cnic_sock ) *MAX_CM_SK_TBL_SZ ,GFP_KERNEL );if (!cp->csk_tbl)return -ENOMEM ; +get_random_bytes (&port_id,sizeof (port_id)); + port_id %=CNIC_LOCAL_PORT_RANGE ;if (cnic_init_id_tbl (&cp->csk_port_tbl,CNIC_LOCAL_PORT_RANGE , -CNIC_LOCAL_PORT_MIN )) { +CNIC_LOCAL_PORT_MIN , port_id)) {cnic_cm_free_mem (dev);return -ENOMEM ; }
@@ -4829,7 +4833,7 @@ static int cnic_start_bnx2x_hw(struct cnic_dev *dev) pfid = cp->pfid; ret =cnic_init_id_tbl (&cp->cid_tbl,MAX_ISCSI_TBL_SZ , - cp->iscsi_start_cid); + cp->iscsi_start_cid,0 );if (ret)return -ENOMEM ;
@@ -4837,7 +4841,7 @@ static int cnic_start_bnx2x_hw(struct cnic_dev *dev)if (BNX2X_CHIP_IS_E2 (cp->chip_id)) { ret =cnic_init_id_tbl (&cp->fcoe_cid_tbl,BNX2X_FCOE_NUM_CONNECTIONS , - cp->fcoe_start_cid); + cp->fcoe_start_cid,0 );if (ret)return -ENOMEM ;
Signature · 1 line
1.6.4.GIT
PATCH 4/5 cnic: Improve NETDEV_UP event handling
During NETDEV_UP, we use symbol_get() to get the net driver's cnic probe function. This sometimes doesn't work if NETDEV_UP happens right after NETDEV_REGISTER and the net driver is still running module init code. As a result, the cnic device may not be discovered. We fix this by probing on all NETDEV events if the device's netif_running state is up.
--- drivers/net/cnic.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/cnic.c +2 -2
@@ -5342,7 +5342,7 @@ static int cnic_netdev_event(struct notifier_block *this, unsigned long event, dev =cnic_from_netdev (netdev); -if (!dev && (event ==NETDEV_REGISTER || event ==NETDEV_UP )) { +if (!dev && (event ==NETDEV_REGISTER ||netif_running (netdev))) {/* Check for the hot-plug device */ dev =is_cnic_dev (netdev);if (dev) {
@@ -5358,7 +5358,7 @@ static int cnic_netdev_event(struct notifier_block *this, unsigned long event,else if (event ==NETDEV_UNREGISTER )cnic_ulp_exit (dev); -if (event ==NETDEV_UP ) { +if (event ==NETDEV_UP || (new_dev &&netif_running (netdev))) {if (cnic_register_netdev (dev) !=0 ) {cnic_put (dev); goto done;
Signature · 1 line
1.6.4.GIT
PATCH 5/5 cnic, bnx2: Check iSCSI support early in bnx2_init_one()
Based on earlier patch from Neil Horman <[email protected]>
If iSCSI is not supported on a bnx2 device, bnx2_cnic_probe() will return NULL and the cnic device will not be visible to bnx2i. This will prevent bnx2i from registering and then unregistering during cnic_start() and cause the warning message:
bnx2 0003:01:00.1: eth1: Failed waiting for ULP up call to complete
--- drivers/net/bnx2.c | 7 +++++++ drivers/net/cnic.c | 12 ++---------- 2 files changed, 9 insertions(+), 10 deletions(-)
drivers/net/bnx2.c +7 -0
@@ -416,6 +416,9 @@ struct cnic_eth_dev *bnx2_cnic_probe(struct net_device *dev)struct bnx2 *bp =netdev_priv (dev);struct cnic_eth_dev *cp = &bp->cnic_eth_dev; +if (!cp->max_iscsi_conn) +return NULL ; + cp->drv_owner =THIS_MODULE ; cp->chip_id = bp->chip_id; cp->pdev = bp->pdev;
@@ -8177,6 +8180,10 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev) bp->timer.data = (unsigned long ) bp; bp->timer.function = bnx2_timer; +#ifdef BCM_CNIC + bp->cnic_eth_dev.max_iscsi_conn = +bnx2_reg_rd_ind (bp,BNX2_FW_MAX_ISCSI_CONN ); +#endif pci_save_state (pdev);return 0 ;
drivers/net/cnic.c +2 -10
@@ -4225,14 +4225,6 @@ static void cnic_enable_bnx2_int(struct cnic_dev *dev) BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | cp->last_status_idx); } -static void cnic_get_bnx2_iscsi_info (struct cnic_dev *dev) -{ -u32 max_conn; - - max_conn =cnic_reg_rd_ind (dev,BNX2_FW_MAX_ISCSI_CONN ); - dev->max_iscsi_conn = max_conn; -} -static void cnic_disable_bnx2_int_sync (struct cnic_dev *dev) {struct cnic_local *cp = dev->cnic_priv;
@@ -4557,8 +4549,6 @@ static int cnic_start_bnx2_hw(struct cnic_dev *dev)return err; } -cnic_get_bnx2_iscsi_info (dev); -return 0 ; }
@@ -5224,6 +5214,8 @@ static struct cnic_dev *init_bnx2_cnic(struct net_device *dev) cdev->pcidev = pdev; cp->chip_id = ethdev->chip_id; + cdev->max_iscsi_conn = ethdev->max_iscsi_conn; + cp->cnic_ops = &cnic_bnx2_ops; cp->start_hw = cnic_start_bnx2_hw; cp->stop_hw = cnic_stop_bnx2_hw;
Signature · 1 line
1.6.4.GIT
From: "Michael Chan" <[email protected]>
Date: Wed, 8 Jun 2011 22:29:32 -0700
Quoted 6 lines
We need to keep looping until
cnic_get_kcqes()returns 0.cnic_get_kcqes()returns a maximum of 64 entries. If there are more entries in the queue and we don't loop back, the remaining entries may not be serviced for a long time.Signed-off-by Michael Chan <[email protected]>
Applied.
Re: [PATCH 2/5 net-next] cnic: Fix race conditions with firmware
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Wed, 8 Jun 2011 22:29:33 -0700
Quoted 7 lines
During iSCSI connection terminations, if the target is also terminating at about the same time, the firmware may not complete the driver's request to close or reset the connection. This is fixed by handling other events (instead of the expected completion event) as an indication that the driver's request has been rejected.
Signed-off-by Michael Chan <[email protected]>
Applied.
Re: [PATCH 3/5 net-next] cnic: Randomize initial TCP port for iSCSI connections
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Wed, 8 Jun 2011 22:29:34 -0700
Quoted 6 lines
From: Eddie Wai <[email protected]>
This reduces the likelihood of port re-use when re-loading the driver.
Signed-off-by Eddie Wai <[email protected]>Signed-off-by Michael Chan <[email protected]>
Applied.
Re: [PATCH 4/5 net-next] cnic: Improve NETDEV_UP event handling
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Wed, 8 Jun 2011 22:29:35 -0700
Quoted 8 lines
During
NETDEV_UP, we usesymbol_get()to get the net driver's cnic probe function. This sometimes doesn't work ifNETDEV_UPhappens right afterNETDEV_REGISTERand the net driver is still running module init code. As a result, the cnic device may not be discovered. We fix this by probing on all NETDEV events if the device'snetif_runningstate is up.Signed-off-by Michael Chan <[email protected]>
Applied.
Re: [PATCH 5/5 net-next] cnic, bnx2: Check iSCSI support early in bnx2_init_one()
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Wed, 8 Jun 2011 22:29:36 -0700
Quoted 11 lines
Based on earlier patch from Neil Horman <[email protected]>
If iSCSI is not supported on a bnx2 device,
bnx2_cnic_probe()will return NULL and the cnic device will not be visible to bnx2i. This will prevent bnx2i from registering and then unregistering duringcnic_start()and cause the warning message:bnx2 0003:01:00.1: eth1: Failed waiting for ULP up call to complete
Signed-off-by Michael Chan <[email protected]>Cc Neil Horman <[email protected]>
Applied.
Re: [PATCH 5/5 net-next] cnic, bnx2: Check iSCSI support early in bnx2_init_one()
In reply to Michael ChanQuoted 11 lines · Michael Chan
Based on earlier patch from Neil Horman <[email protected]>
If iSCSI is not supported on a bnx2 device,
bnx2_cnic_probe()will return NULL and the cnic device will not be visible to bnx2i. This will prevent bnx2i from registering and then unregistering duringcnic_start()and cause the warning message:bnx2 0003:01:00.1: eth1: Failed waiting for ULP up call to complete
Signed-off-by Michael Chan <[email protected]>Cc Neil Horman <[email protected]>
Thank you Michael. This also lets you eliminate some dead code in bnx2i_start now, since cdev->max_iscsi_conn will never be zero.
Regards
Neil
Quoted 1 line
Re: [PATCH 3/5 net-next] cnic: Randomize initial TCP port for iSCSI connections
In reply to Michael Chandrivers/net/cnic.c static void cnic_cm_free_mem(struct cnic_dev *dev) · line 3815
Quoted 11 lines · On Wed, 8 Jun 2011 22:29:34 -0700 "Michael Chan" <[email protected]> wrote:
static int
cnic_cm_alloc_mem(struct cnic_dev *dev){drivers/net/cnic.c +2
-0struct cnic_local *cp = dev->cnic_priv; +u32 port_id; cp->csk_tbl =kzalloc (sizeof (struct cnic_sock ) *MAX_CM_SK_TBL_SZ ,GFP_KERNEL );if (!cp->csk_tbl)return -ENOMEM ; +get_random_bytes (&port_id,sizeof (port_id));
I think random32() or it's alias net_random() would be sufficient for your needs here.
Re: [PATCH 5/5 net-next] cnic, bnx2: Check iSCSI support early in bnx2_init_one()
In reply to Neil HormanQuoted 8 lines · Neil Horman
Quoted 7 lines · Michael Chan
Based on earlier patch from Neil Horman <[email protected]>
If iSCSI is not supported on a bnx2 device,
bnx2_cnic_probe()will return NULL and the cnic device will not be visible to bnx2i. This will prevent bnx2i from registering and then unregistering duringcnic_start()and cause the warning message:
Quoted 7 lines
Quoted 4 lines
bnx2 0003:01:00.1: eth1: Failed waiting for ULP up call to complete
Signed-off-by Michael Chan <[email protected]>Cc Neil Horman <[email protected]>Thank you Michael. This also lets you eliminate some dead code in
bnx2i_startnow, sincecdev->max_iscsi_connwill never be zero.
This is true for bnx2. For bnx2x, some devices may support FCoE only and not iSCSI, so we still need code similar to what you proposed yesterday. We'll add that through the scsi tree.
Thanks.
Re: [PATCH 3/5 net-next] cnic: Randomize initial TCP port for iSCSI connections
In reply to Stephen HemmingerQuoted 13 lines · Stephen Hemminger
Quoted 10 lines · On Wed, 8 Jun 2011 22:29:34 -0700 "Michael Chan" <[email protected]> wrote:
static int
cnic_cm_alloc_mem(struct cnic_dev *dev){drivers/net/cnic.c +1
-0struct cnic_local *cp = dev->cnic_priv; +u32 port_id; cp->csk_tbl =kzalloc (sizeof (struct cnic_sock ) *MAX_CM_SK_TBL_SZ ,GFP_KERNEL );if (!cp->csk_tbl)return -ENOMEM ;
Quoted 5 lines
drivers/net/cnic.c static void cnic_cm_free_mem(struct cnic_dev *dev) · line 3815
Quoted 1 line
drivers/net/cnic.c +1
-0+get_random_bytes (&port_id,sizeof (port_id));I think
random32()or it's aliasnet_random()would be sufficient for your needs here.
random32() is pseudo random so we can get the same number after reboot, right? One scenario is that we may be booting from an iSCSI target, but due to some failure, the user may be rebooting multiple times rapidly. We want to use a different port during each boot.
Re: [PATCH 3/5 net-next] cnic: Randomize initial TCP port for iSCSI connections
Quoted 21 lines · On Thu, 9 Jun 2011 18:08:00 -0700 "Michael Chan" <[email protected]> wrote:
Quoted 13 lines · Stephen Hemminger
Quoted 10 lines · On Wed, 8 Jun 2011 22:29:34 -0700 "Michael Chan" <[email protected]> wrote:
static int
cnic_cm_alloc_mem(struct cnic_dev *dev){drivers/net/cnic.c +1
-0struct cnic_local *cp = dev->cnic_priv; +u32 port_id; cp->csk_tbl =kzalloc (sizeof (struct cnic_sock ) *MAX_CM_SK_TBL_SZ ,GFP_KERNEL );if (!cp->csk_tbl)return -ENOMEM ;Quoted 5 lines
drivers/net/cnic.c static void cnic_cm_free_mem(struct cnic_dev *dev) · line 3815
Quoted 1 line
drivers/net/cnic.c +1
-0+get_random_bytes (&port_id,sizeof (port_id));I think
random32()or it's aliasnet_random()would be sufficient for your needs here.
Quoted 4 lines
random32()is pseudo random so we can get the same number after reboot, right? One scenario is that we may be booting from an iSCSI target, but due to some failure, the user may be rebooting multiple times rapidly. We want to use a different port during each boot.
random32 is seeded off get_random_bytes at boot.
Re: [PATCH 3/5 net-next] cnic: Randomize initial TCP port for iSCSI connections
Quoted 24 lines · Stephen Hemminger
Quoted 21 lines · On Thu, 9 Jun 2011 18:08:00 -0700 "Michael Chan" <[email protected]> wrote:
Quoted 18 lines · Stephen Hemminger
drivers/net/cnic.c static void cnic_cm_free_mem(struct cnic_dev *dev) · line 3815
Quoted 11 lines · On Wed, 8 Jun 2011 22:29:34 -0700 "Michael Chan" <[email protected]> wrote:
static int
cnic_cm_alloc_mem(struct cnic_dev *dev){drivers/net/cnic.c +2
-0struct cnic_local *cp = dev->cnic_priv; +u32 port_id; cp->csk_tbl =kzalloc (sizeof (struct cnic_sock ) *MAX_CM_SK_TBL_SZ ,GFP_KERNEL );if (!cp->csk_tbl)return -ENOMEM ; +get_random_bytes (&port_id,sizeof (port_id));I think
random32()or it's aliasnet_random()would be sufficient for your needs here.
Quoted 6 lines
Quoted 4 lines
random32()is pseudo random so we can get the same number after reboot, right? One scenario is that we may be booting from an iSCSI target, but due to some failure, the user may be rebooting multiple times rapidly. We want to use a different port during each boot.random32 is seeded off
get_random_bytesat boot.
cnic_cm_alloc_mem() is apparently called one time per boot, it seems OK to call get_random_bytes() in this case ?
Re: [PATCH 3/5 net-next] cnic: Randomize initial TCP port for iSCSI connections
In reply to Stephen HemmingerQuoted 8 lines · Stephen Hemminger
Quoted 4 lines · On Thu, 9 Jun 2011 18:08:00 -0700 "Michael Chan" <[email protected]> wrote:
random32()is pseudo random so we can get the same number after reboot, right? One scenario is that we may be booting from an iSCSI target, but due to some failure, the user may be rebooting multiple times rapidly. We want to use a different port during each boot.random32 is seeded off
get_random_bytesat boot.
Thanks. We'll change it to random32() in our next patchset then.