cnic: Add functions to allocate and free UIO rings
Subsystems (2)
PATCH 1/5 cnic: Add functions to allocate and free UIO rings
These functions are needed to free up memory when the rings are no longer needed.
--- drivers/net/ethernet/broadcom/cnic.c | 59 +++++++++++++++++++++++----------- 1 files changed, 40 insertions(+), 19 deletions(-)
drivers/net/ethernet/broadcom/cnic.c +40 -19
@@ -823,10 +823,8 @@ static void cnic_free_context(struct cnic_dev *dev) } } -static void __cnic_free_uio (struct cnic_uio_dev *udev) +static void __cnic_free_uio_rings (struct cnic_uio_dev *udev) { -uio_unregister_device (&udev->cnic_uinfo); -if (udev->l2_buf) {dma_free_coherent (&udev->pdev->dev, udev->l2_buf_size, udev->l2_buf, udev->l2_buf_map);
@@ -839,6 +837,14 @@ static void __cnic_free_uio(struct cnic_uio_dev *udev) udev->l2_ring =NULL ; } +} + +static void __cnic_free_uio (struct cnic_uio_dev *udev) +{ +uio_unregister_device (&udev->cnic_uinfo); + +__cnic_free_uio_rings (udev); +pci_dev_put (udev->pdev);kfree (udev); }
@@ -996,6 +1002,34 @@ static int cnic_alloc_kcq(struct cnic_dev *dev, struct kcq_info *info,return 0 ; } +static int __cnic_alloc_uio_rings (struct cnic_uio_dev *udev,int pages) +{ +struct cnic_local *cp = udev->dev->cnic_priv; + +if (udev->l2_ring) +return 0 ; + + udev->l2_ring_size = pages *BCM_PAGE_SIZE ; + udev->l2_ring =dma_alloc_coherent (&udev->pdev->dev, udev->l2_ring_size, + &udev->l2_ring_map, +GFP_KERNEL | __GFP_COMP); +if (!udev->l2_ring) +return -ENOMEM ; + + udev->l2_buf_size = (cp->l2_rx_ring_size +1 ) * cp->l2_single_buf_size; + udev->l2_buf_size =PAGE_ALIGN (udev->l2_buf_size); + udev->l2_buf =dma_alloc_coherent (&udev->pdev->dev, udev->l2_buf_size, + &udev->l2_buf_map, +GFP_KERNEL | __GFP_COMP); +if (!udev->l2_buf) { +__cnic_free_uio_rings (udev); +return -ENOMEM ; + } + +return 0 ; + +} +static int cnic_alloc_uio_rings (struct cnic_dev *dev,int pages) {struct cnic_local *cp = dev->cnic_priv;
@@ -1020,20 +1054,9 @@ static int cnic_alloc_uio_rings(struct cnic_dev *dev, int pages) udev->dev = dev; udev->pdev = dev->pcidev; - udev->l2_ring_size = pages *BCM_PAGE_SIZE ; - udev->l2_ring =dma_alloc_coherent (&udev->pdev->dev, udev->l2_ring_size, - &udev->l2_ring_map, -GFP_KERNEL | __GFP_COMP); -if (!udev->l2_ring) - goto err_udev; - udev->l2_buf_size = (cp->l2_rx_ring_size +1 ) * cp->l2_single_buf_size; - udev->l2_buf_size =PAGE_ALIGN (udev->l2_buf_size); - udev->l2_buf =dma_alloc_coherent (&udev->pdev->dev, udev->l2_buf_size, - &udev->l2_buf_map, -GFP_KERNEL | __GFP_COMP); -if (!udev->l2_buf) - goto err_dma; +if (__cnic_alloc_uio_rings (udev, pages)) + goto err_udev;write_lock (&cnic_dev_lock);list_add (&udev->list, &cnic_udev_list);
@@ -1044,9 +1067,7 @@ static int cnic_alloc_uio_rings(struct cnic_dev *dev, int pages) cp->udev = udev;return 0 ; - err_dma: -dma_free_coherent (&udev->pdev->dev, udev->l2_ring_size, - udev->l2_ring, udev->l2_ring_map); + err_udev:kfree (udev);return -ENOMEM ;
Signature · 1 line
1.7.1
PATCH 2/5 cnic: Free UIO rings when the device is closed.
This will free up unneeded memory.
--- drivers/net/ethernet/broadcom/cnic.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/net/ethernet/broadcom/cnic.c +7 -0
@@ -868,6 +868,8 @@ static void cnic_free_resc(struct cnic_dev *dev)if (udev) { udev->dev =NULL ; cp->udev =NULL ; +if (udev->uio_dev ==-1 ) +__cnic_free_uio_rings (udev); }cnic_free_context (dev);
@@ -1039,6 +1041,11 @@ static int cnic_alloc_uio_rings(struct cnic_dev *dev, int pages)list_for_each_entry (udev, &cnic_udev_list, list) {if (udev->pdev == dev->pcidev) { udev->dev = dev; +if (__cnic_alloc_uio_rings (udev, pages)) { + udev->dev =NULL ; +read_unlock (&cnic_dev_lock); +return -ENOMEM ; + } cp->udev = udev;read_unlock (&cnic_dev_lock);return 0 ;
Signature · 1 line
1.7.1
PATCH 3/5 cnic: Add function pointers to arm IRQ for different devices.
This will make it easier to exit IRQ loop and re-arm IRQ on devices that don't support FCoE.
--- drivers/net/ethernet/broadcom/cnic.c | 26 ++++++++++++++++++++++---- drivers/net/ethernet/broadcom/cnic.h | 1 + 2 files changed, 23 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/cnic.c +22 -4
@@ -3078,6 +3078,22 @@ static void cnic_ack_bnx2x_e2_msix(struct cnic_dev *dev) IGU_INT_DISABLE, 0); } +static void cnic_arm_bnx2x_msix (struct cnic_dev *dev,u32 idx) +{ +struct cnic_local *cp = dev->cnic_priv; + +cnic_ack_bnx2x_int (dev, cp->bnx2x_igu_sb_id,CSTORM_ID , idx, +IGU_INT_ENABLE ,1 ); +} + +static void cnic_arm_bnx2x_e2_msix (struct cnic_dev *dev,u32 idx) +{ +struct cnic_local *cp = dev->cnic_priv; + +cnic_ack_igu_sb (dev, cp->bnx2x_igu_sb_id,IGU_SEG_ACCESS_DEF , idx, +IGU_INT_ENABLE ,1 ); +} +static u32 cnic_service_bnx2x_kcq (struct cnic_dev *dev,struct kcq_info *info) {u32 last_status = *info->status_idx_ptr;
@@ -3115,8 +3131,7 @@ static void cnic_service_bnx2x_bh(unsigned long data) cp->kcq1.sw_prod_idx + MAX_KCQ_IDX);if (!BNX2X_CHIP_IS_E2_PLUS (cp->chip_id)) { -cnic_ack_bnx2x_int (dev, cp->bnx2x_igu_sb_id,USTORM_ID , - status_idx,IGU_INT_ENABLE ,1 ); + cp->arm_int (dev, status_idx);break ; }
@@ -5520,10 +5535,13 @@ static struct cnic_dev *init_bnx2x_cnic(struct net_device *dev) cp->stop_cm = cnic_cm_stop_bnx2x_hw; cp->enable_int = cnic_enable_bnx2x_int; cp->disable_int_sync = cnic_disable_bnx2x_int_sync; -if (BNX2X_CHIP_IS_E2_PLUS (cp->chip_id)) +if (BNX2X_CHIP_IS_E2_PLUS (cp->chip_id)) { cp->ack_int = cnic_ack_bnx2x_e2_msix; -else + cp->arm_int = cnic_arm_bnx2x_e2_msix; + }else { cp->ack_int = cnic_ack_bnx2x_msix; + cp->arm_int = cnic_arm_bnx2x_msix; + } cp->close_conn = cnic_close_bnx2x_conn;return cdev; }
drivers/net/ethernet/broadcom/cnic.h +1 -0
@@ -334,6 +334,7 @@ struct cnic_local {void (*enable_int)(struct cnic_dev *);void (*disable_int_sync)(struct cnic_dev *);void (*ack_int)(struct cnic_dev *); +void (*arm_int)(struct cnic_dev *,u32 index);void (*close_conn)(struct cnic_sock *,u32 opcode); };
Signature · 1 line
1.7.1
PATCH 4/5 cnic: Allocate kcq resource only on devices that support FCoE.
To save memory and to exit IRQ loop quicker on devices that don't support FCoE.
--- drivers/net/ethernet/broadcom/cnic.c | 7 +++---- drivers/net/ethernet/broadcom/cnic.h | 4 ++++ 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/cnic.c +3 -4
@@ -1288,7 +1288,7 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev)if (ret) goto error; -if (BNX2X_CHIP_IS_E2_PLUS (cp->chip_id)) { +if (CNIC_SUPPORTS_FCOE (cp)) { ret =cnic_alloc_kcq (dev, &cp->kcq2, true);if (ret) goto error;
@@ -3130,7 +3130,7 @@ static void cnic_service_bnx2x_bh(unsigned long data)CNIC_WR16 (dev, cp->kcq1.io_addr, cp->kcq1.sw_prod_idx +MAX_KCQ_IDX ); -if (!BNX2X_CHIP_IS_E2_PLUS (cp->chip_id)) { +if (cp->ethdev->drv_state &CNIC_DRV_STATE_NO_FCOE ) { cp->arm_int (dev, status_idx);break ; }
@@ -5516,8 +5516,7 @@ static struct cnic_dev *init_bnx2x_cnic(struct net_device *dev)if (!(ethdev->drv_state &CNIC_DRV_STATE_NO_ISCSI )) cdev->max_iscsi_conn = ethdev->max_iscsi_conn; -if (BNX2X_CHIP_IS_E2_PLUS (cp->chip_id) && - !(ethdev->drv_state &CNIC_DRV_STATE_NO_FCOE )) +if (CNIC_SUPPORTS_FCOE (cp)) cdev->max_fcoe_conn = ethdev->max_fcoe_conn;if (cdev->max_fcoe_conn >BNX2X_FCOE_NUM_CONNECTIONS )
drivers/net/ethernet/broadcom/cnic.h +4 -0
@@ -475,6 +475,10 @@ struct bnx2x_bd_chain_next { MAX_STAT_COUNTER_ID_E1))#endif +#define CNIC_SUPPORTS_FCOE (cp) \ + (BNX2X_CHIP_IS_E2_PLUS((cp)->chip_id) && \ + !((cp)->ethdev->drv_state & CNIC_DRV_STATE_NO_FCOE)) +#define CNIC_RAMROD_TMO (HZ / 4)#endif
Signature · 1 line
1.7.1
PATCH 5/5 cnic: Allocate UIO resources only on devices that support iSCSI.
Update version to 2.5.13.
--- drivers/net/ethernet/broadcom/cnic.c | 5 ++++- drivers/net/ethernet/broadcom/cnic_if.h | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/cnic.c +4 -1
@@ -1303,6 +1303,9 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev)if (ret) goto error; +if (cp->ethdev->drv_state &CNIC_DRV_STATE_NO_ISCSI ) +return 0 ; + cp->bnx2x_def_status_blk = cp->ethdev->irq_arr[1 ].status_blk; cp->l2_rx_ring_size =15 ;
@@ -5351,7 +5354,7 @@ static void cnic_stop_hw(struct cnic_dev *dev)/* Need to wait for the ring shutdown event to complete * before clearing the CNIC_UP flag. */ -while (cp->udev->uio_dev !=-1 && i <15 ) { +while (cp->udev && cp->udev->uio_dev !=-1 && i <15 ) {msleep (100 ); i++; }
drivers/net/ethernet/broadcom/cnic_if.h +2 -2
@@ -14,8 +14,8 @@#include "bnx2x/bnx2x_mfw_req.h" -#define CNIC_MODULE_VERSION "2.5.12" -#define CNIC_MODULE_RELDATE "June 29, 2012" +#define CNIC_MODULE_VERSION "2.5.13" +#define CNIC_MODULE_RELDATE "Sep 07, 2012"#define CNIC_ULP_RDMA 0#define CNIC_ULP_ISCSI 1
Signature · 1 line
1.7.1
Re: [PATCH net-next 5/5] cnic: Allocate UIO resources only on devices that support iSCSI.
From: "Michael Chan" <[email protected]>
Date: Sat, 8 Sep 2012 09:01:05 -0700
Quoted 5 lines
Update version to 2.5.13.
Reviewed-by Eddie Wai <[email protected]>Reviewed-by Bhanu Prakash Gollapudi <[email protected]>Signed-off-by Michael Chan <[email protected]>
Applied.
Re: [PATCH net-next 4/5] cnic: Allocate kcq resource only on devices that support FCoE.
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Sat, 8 Sep 2012 09:01:04 -0700
Quoted 6 lines
To save memory and to exit IRQ loop quicker on devices that don't support FCoE.
Reviewed-by Eddie Wai <[email protected]>Reviewed-by Bhanu Prakash Gollapudi <[email protected]>Signed-off-by Michael Chan <[email protected]>
Applied.
Re: [PATCH net-next 3/5] cnic: Add function pointers to arm IRQ for different devices.
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Sat, 8 Sep 2012 09:01:03 -0700
Quoted 6 lines
This will make it easier to exit IRQ loop and re-arm IRQ on devices that don't support FCoE.
Reviewed-by Eddie Wai <[email protected]>Reviewed-by Bhanu Prakash Gollapudi <[email protected]>Signed-off-by Michael Chan <[email protected]>
Applied.
Re: [PATCH net-next 2/5] cnic: Free UIO rings when the device is closed.
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Sat, 8 Sep 2012 09:01:02 -0700
Quoted 5 lines
This will free up unneeded memory.
Reviewed-by Eddie Wai <[email protected]>Reviewed-by Bhanu Prakash Gollapudi <[email protected]>Signed-off-by Michael Chan <[email protected]>
Applied.
From: "Michael Chan" <[email protected]>
Date: Sat, 8 Sep 2012 09:01:01 -0700
Quoted 6 lines
These functions are needed to free up memory when the rings are no longer needed.
Reviewed-by Eddie Wai <[email protected]>Reviewed-by Bhanu Prakash Gollapudi <[email protected]>Signed-off-by Michael Chan <[email protected]>
Applied.