Skip to contentSkip to conversation

bna: Update bna driver version to 3.0.2.1

PATCH In review Rasesh Mody 3 participants 26 messages Aug 16, 2011 – Aug 17, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover bna: Update bna driver version to 3.0.2.1

Hello David,

The following patch set contains changes for adding support for feature like Multi TXQ, TX and RX path changes and Ethtool enhancements. This also fixes bugs found with new code. It cleans up unused code, formatting changes and comments addition/deletion.

This updates the Brocade BNA driver to v3.0.2.1.

The driver has been compiled & tested against net-next-2.6(3.0.0-rc7)

Thanks,
Rasesh

Rasesh Mody (14):
bna: Naming Change and Minor Macro Fix
bna: PCI Probe Fix
bna: Interrupt Polling and NAPI Init Changes
bna: Add Multiple Tx Queue Support
bna: SKB Check and Drop Macros
bna: TX Path and RX Path Changes
bna: Formatting and Code Cleanup
bna: Initialization and Locking Fix
bna: Ethtool Enhancements and Fix
bna: Async Mode Tx Rx Init Fix
bna: MBOX IRQ Flag Check after Locking
bna: Queue Depth and SKB Unmap Array Fix
bna: SKB PCI UNMAP Fix
bna: Driver Version changed to 3.0.2.1

 drivers/net/ethernet/brocade/bna/bfa_cee.c         |    2 -
 drivers/net/ethernet/brocade/bna/bfa_defs.h        |    8 +-
 .../net/ethernet/brocade/bna/bfa_defs_mfg_comm.h   |    1 -
 drivers/net/ethernet/brocade/bna/bfa_ioc.h         |    6 +-
 drivers/net/ethernet/brocade/bna/bfi.h             |   46 --
 drivers/net/ethernet/brocade/bna/bna.h             |   26 +-
 drivers/net/ethernet/brocade/bna/bna_enet.c        |   29 +-
 drivers/net/ethernet/brocade/bna/bna_hw_defs.h     |    5 +
 drivers/net/ethernet/brocade/bna/bna_types.h       |    2 +-
 drivers/net/ethernet/brocade/bna/bnad.c            |  628 ++++++++++++--------
 drivers/net/ethernet/brocade/bna/bnad.h            |   98 +++-
 drivers/net/ethernet/brocade/bna/bnad_ethtool.c    |   96 +++-
 drivers/net/ethernet/brocade/bna/cna.h             |   11 +-
 13 files changed, 576 insertions(+), 382 deletions(-)
#1 lore raw

PATCH 1/14 bna: Naming Change and Minor Macro Fix

Naming changes: rename devid, BNAD_MAX_TXS, BNAD_MAX_RXS, BNAD_MAX_RXPS_PER_RX to device, BNAD_MAX_TX, BNAD_MAX_RX, BNAD_MAX_RXP_PER_RX respectively and change all the references.

Macro Fix: Add ioc_isr_mod_set check to bfa_nw_ioc_mbox_regisr macro

---
 drivers/net/ethernet/brocade/bna/bfa_defs.h |    8 ++++----
 drivers/net/ethernet/brocade/bna/bfa_ioc.h  |    6 ++++--
 drivers/net/ethernet/brocade/bna/bnad.c     |    6 +++---
 drivers/net/ethernet/brocade/bna/bnad.h     |   20 ++++++++++----------
 4 files changed, 21 insertions(+), 19 deletions(-)
drivers/net/ethernet/brocade/bna/bfa_defs.h +4 -4
index 205b92b..a81c0cc 100644
@@ -251,10 +251,10 @@ struct bfa_mfg_block {
  * ---------------------- pci definitions ------------
  */
 
-#define bfa_asic_id_ct(devid)			\
-	((devid) == PCI_DEVICE_ID_BROCADE_CT ||	\
-	(devid) == PCI_DEVICE_ID_BROCADE_CT_FC)
-#define bfa_asic_id_ctc(devid) (bfa_asic_id_ct(devid))
+#define bfa_asic_id_ct(device)			\
+	((device) == PCI_DEVICE_ID_BROCADE_CT ||	\
+	 (device) == PCI_DEVICE_ID_BROCADE_CT_FC)
+#define bfa_asic_id_ctc(device) (bfa_asic_id_ct(device))
 
 enum bfa_mode {
 	BFA_MODE_HBA		= 1,
drivers/net/ethernet/brocade/bna/bfa_ioc.h +4 -2
index f5a3d4e..9116324 100644
@@ -274,8 +274,10 @@ void bfa_nw_ioc_mbox_regisr(struct bfa_ioc *ioc, enum bfi_mclass mc,
 	((__ioc)->ioc_hwif->ioc_pll_init((__ioc)->pcidev.pci_bar_kva, \
 			   (__ioc)->asic_mode))
 
-#define	bfa_ioc_isr_mode_set(__ioc, __msix)			\
-			((__ioc)->ioc_hwif->ioc_isr_mode_set(__ioc, __msix))
+#define	bfa_ioc_isr_mode_set(__ioc, __msix) do {			\
+	if ((__ioc)->ioc_hwif->ioc_isr_mode_set)			\
+		((__ioc)->ioc_hwif->ioc_isr_mode_set(__ioc, __msix));	\
+} while (0)
 #define	bfa_ioc_ownership_reset(__ioc)				\
 			((__ioc)->ioc_hwif->ioc_ownership_reset(__ioc))
 
drivers/net/ethernet/brocade/bna/bnad.c +3 -3
index 5ad07ea..bc5bfa7 100644
@@ -1001,7 +1001,7 @@ bnad_cb_rx_cleanup(struct bnad *bnad, struct bna_rx *rx)
 
 	mdelay(BNAD_TXRX_SYNC_MDELAY);
 
-	for (i = 0; i < BNAD_MAX_RXPS_PER_RX; i++) {
+	for (i = 0; i < BNAD_MAX_RXP_PER_RX; i++) {
 		rx_ctrl = &rx_info->rx_ctrl[i];
 		ccb = rx_ctrl->ccb;
 		if (!ccb)
@@ -1030,7 +1030,7 @@ bnad_cb_rx_post(struct bnad *bnad, struct bna_rx *rx)
 	int i;
 	int j;
 
-	for (i = 0; i < BNAD_MAX_RXPS_PER_RX; i++) {
+	for (i = 0; i < BNAD_MAX_RXP_PER_RX; i++) {
 		rx_ctrl = &rx_info->rx_ctrl[i];
 		ccb = rx_ctrl->ccb;
 		if (!ccb)
@@ -2227,7 +2227,7 @@ bnad_q_num_init(struct bnad *bnad)
 	int rxps;
 
 	rxps = min((uint)num_online_cpus(),
-			(uint)(BNAD_MAX_RXS * BNAD_MAX_RXPS_PER_RX));
+			(uint)(BNAD_MAX_RX * BNAD_MAX_RXP_PER_RX));
 
 	if (!(bnad->cfg_flags & BNAD_CF_MSIX))
 		rxps = 1;	/* INTx */
drivers/net/ethernet/brocade/bna/bnad.h +10 -10
index 5b5451e..3c23139 100644
@@ -38,12 +38,12 @@
 #define BNAD_TXQ_DEPTH		2048
 #define BNAD_RXQ_DEPTH		2048
 
-#define BNAD_MAX_TXS		1
+#define BNAD_MAX_TX		1
 #define BNAD_MAX_TXQ_PER_TX	8	/* 8 priority queues */
 #define BNAD_TXQ_NUM		1
 
-#define BNAD_MAX_RXS		1
-#define BNAD_MAX_RXPS_PER_RX	16
+#define BNAD_MAX_RX		1
+#define BNAD_MAX_RXP_PER_RX	16
 #define BNAD_MAX_RXQ_PER_RXP	2
 
 /*
@@ -190,7 +190,7 @@ struct bnad_tx_info {
 struct bnad_rx_info {
 	struct bna_rx *rx; /* 1:1 between rx_info & rx */
 
-	struct bnad_rx_ctrl rx_ctrl[BNAD_MAX_RXPS_PER_RX];
+	struct bnad_rx_ctrl rx_ctrl[BNAD_MAX_RXP_PER_RX];
 	u32 rx_id;
 } ____cacheline_aligned;
 
@@ -234,8 +234,8 @@ struct bnad {
 	struct net_device	*netdev;
 
 	/* Data path */
-	struct bnad_tx_info tx_info[BNAD_MAX_TXS];
-	struct bnad_rx_info rx_info[BNAD_MAX_RXS];
+	struct bnad_tx_info tx_info[BNAD_MAX_TX];
+	struct bnad_rx_info rx_info[BNAD_MAX_RX];
 
 	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
 	/*
@@ -255,8 +255,8 @@ struct bnad {
 	u8			tx_coalescing_timeo;
 	u8			rx_coalescing_timeo;
 
-	struct bna_rx_config rx_config[BNAD_MAX_RXS];
-	struct bna_tx_config tx_config[BNAD_MAX_TXS];
+	struct bna_rx_config rx_config[BNAD_MAX_RX];
+	struct bna_tx_config tx_config[BNAD_MAX_TX];
 
 	void __iomem		*bar0;	/* BAR0 address */
 
@@ -283,8 +283,8 @@ struct bnad {
 	/* Control path resources, memory & irq */
 	struct bna_res_info res_info[BNA_RES_T_MAX];
 	struct bna_res_info mod_res_info[BNA_MOD_RES_T_MAX];
-	struct bnad_tx_res_info tx_res_info[BNAD_MAX_TXS];
-	struct bnad_rx_res_info rx_res_info[BNAD_MAX_RXS];
+	struct bnad_tx_res_info tx_res_info[BNAD_MAX_TX];
+	struct bnad_rx_res_info rx_res_info[BNAD_MAX_RX];
 
 	struct bnad_completion bnad_completions;
 
Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/14 bna: PCI Probe Fix

In reply to Rasesh Mody

Change details:
- Return error as -EIO if bnad_res_alloc fails
- Release the configuration lock before registering with net_device layer.

---
 drivers/net/ethernet/brocade/bna/bnad.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
drivers/net/ethernet/brocade/bna/bnad.c +7 -1
index bc5bfa7..8db7247 100644
@@ -3254,8 +3254,10 @@ bnad_pci_probe(struct pci_dev *pdev,
 	spin_unlock_irqrestore(&bnad->bna_lock, flags);
 
 	err = bnad_res_alloc(bnad, &bnad->mod_res_info[0], BNA_MOD_RES_T_MAX);
-	if (err)
+	if (err) {
+		err = -EIO;
 		goto disable_ioceth;
+	}
 
 	spin_lock_irqsave(&bnad->bna_lock, flags);
 	bna_mod_init(&bnad->bna, &bnad->mod_res_info[0]);
@@ -3267,6 +3269,8 @@ bnad_pci_probe(struct pci_dev *pdev,
 	bnad_set_netdev_perm_addr(bnad);
 	spin_unlock_irqrestore(&bnad->bna_lock, flags);
 
+	mutex_unlock(&bnad->conf_mutex);
+
 	/* Finally, reguister with net_device layer */
 	err = register_netdev(netdev);
 	if (err) {
@@ -3275,6 +3279,8 @@ bnad_pci_probe(struct pci_dev *pdev,
 	}
 	set_bit(BNAD_RF_NETDEV_REGISTERED, &bnad->run_flags);
 
+	return 0;
+
 probe_success:
 	mutex_unlock(&bnad->conf_mutex);
 	return 0;
Signature · 1 line
1.7.1
#3 lore raw

PATCH 3/14 bna: Interrupt Polling and NAPI Init Changes

In reply to Rasesh Mody

Change details:
- Remove unnecessary ccb check from bnad_poll_cq
- Add bnad pointer to rx_ctrl structure, so that bnad can be accessed directly from rx_ctrl in the NAPI poll routines, even if ccb is NULL
- Validate ccb before referencing to it in bnad_msix_rx and bnad_napi_poll_rx
- Fix the order of NAPI init / uninit in Tx / Rx setup / teardown path:
a. Kill bnad tx free tasklet ahead of call to bna_tx_destroy() b. Call NAPI disable only after call to Rx free_irq(). This makes sure Rx
interrupt does not schedule a poll when NAPI is already disabled
- NAPI poll runs before the h/w has completed configuration. This causes a crash. Delay enabling NAPI till after bna_rx_enable(). Split NAPI initialization into 2 steps, bnad_napi_init() & bnad_napi_enable().

---
 drivers/net/ethernet/brocade/bna/bnad.c |   83 ++++++++++++++++++++-----------
 drivers/net/ethernet/brocade/bna/bnad.h |    1 +
 2 files changed, 54 insertions(+), 30 deletions(-)
drivers/net/ethernet/brocade/bna/bnad.c +53 -30
index 8db7247..327b274 100644
@@ -535,16 +535,11 @@ next:
 
 	BNA_QE_INDX_ADD(ccb->producer_index, wis, ccb->q_depth);
 
-	if (likely(ccb)) {
-		if (likely(test_bit(BNAD_RXQ_STARTED, &ccb->rcb[0]->flags)))
-			bna_ib_ack(ccb->i_dbell, packets);
-		bnad_refill_rxq(bnad, ccb->rcb[0]);
-		if (ccb->rcb[1])
-			bnad_refill_rxq(bnad, ccb->rcb[1]);
-	} else {
-		if (likely(test_bit(BNAD_RXQ_STARTED, &ccb->rcb[0]->flags)))
-			bna_ib_ack(ccb->i_dbell, 0);
-	}
+	if (likely(test_bit(BNAD_RXQ_STARTED, &ccb->rcb[0]->flags)))
+		bna_ib_ack(ccb->i_dbell, packets);
+	bnad_refill_rxq(bnad, ccb->rcb[0]);
+	if (ccb->rcb[1])
+		bnad_refill_rxq(bnad, ccb->rcb[1]);
 
 	clear_bit(BNAD_FP_IN_RX_PATH, &rx_ctrl->flags);
 
@@ -590,9 +585,9 @@ static irqreturn_t
 bnad_msix_rx(int irq, void *data)
 {
 	struct bna_ccb *ccb = (struct bna_ccb *)data;
-	struct bnad *bnad = ccb->bnad;
 
-	bnad_netif_rx_schedule_poll(bnad, ccb);
+	if (ccb)
+		bnad_netif_rx_schedule_poll(ccb->bnad, ccb);
 
 	return IRQ_HANDLED;
 }
@@ -1658,18 +1653,14 @@ bnad_napi_poll_rx(struct napi_struct *napi, int budget)
 {
 	struct bnad_rx_ctrl *rx_ctrl =
 		container_of(napi, struct bnad_rx_ctrl, napi);
-	struct bna_ccb *ccb;
-	struct bnad *bnad;
+	struct bnad *bnad = rx_ctrl->bnad;
 	int rcvd = 0;
 
-	ccb = rx_ctrl->ccb;
-
-	bnad = ccb->bnad;
 
 	if (!netif_carrier_ok(bnad->netdev))
 		goto poll_exit;
 
-	rcvd = bnad_poll_cq(bnad, ccb, budget);
+	rcvd = bnad_poll_cq(bnad, rx_ctrl->ccb, budget);
 	if (rcvd == budget)
 		return rcvd;
 
@@ -1678,12 +1669,15 @@ poll_exit:
 
 	BNAD_UPDATE_CTR(bnad, netif_rx_complete);
 
-	bnad_enable_rx_irq(bnad, ccb);
+
+	if (rx_ctrl->ccb)
+		bnad_enable_rx_irq(bnad, rx_ctrl->ccb);
 	return rcvd;
 }
 
+#define BNAD_NAPI_POLL_QUOTA		64
 static void
-bnad_napi_enable(struct bnad *bnad, u32 rx_id)
+bnad_napi_init(struct bnad *bnad, u32 rx_id)
 {
 	struct bnad_rx_ctrl *rx_ctrl;
 	int i;
@@ -1691,9 +1685,20 @@ bnad_napi_enable(struct bnad *bnad, u32 rx_id)
 	/* Initialize & enable NAPI */
 	for (i = 0; i <	bnad->num_rxp_per_rx; i++) {
 		rx_ctrl = &bnad->rx_info[rx_id].rx_ctrl[i];
-
 		netif_napi_add(bnad->netdev, &rx_ctrl->napi,
-			       bnad_napi_poll_rx, 64);
+			       bnad_napi_poll_rx, BNAD_NAPI_POLL_QUOTA);
+	}
+}
+
+static void
+bnad_napi_enable(struct bnad *bnad, u32 rx_id)
+{
+	struct bnad_rx_ctrl *rx_ctrl;
+	int i;
+
+	/* Initialize & enable NAPI */
+	for (i = 0; i <	bnad->num_rxp_per_rx; i++) {
+		rx_ctrl = &bnad->rx_info[rx_id].rx_ctrl[i];
 
 		napi_enable(&rx_ctrl->napi);
 	}
@@ -1732,6 +1737,9 @@ bnad_cleanup_tx(struct bnad *bnad, u32 tx_id)
 		bnad_tx_msix_unregister(bnad, tx_info,
 			bnad->num_txq_per_tx);
 
+	if (0 == tx_id)
+		tasklet_kill(&bnad->tx_free_tasklet);
+
 	spin_lock_irqsave(&bnad->bna_lock, flags);
 	bna_tx_destroy(tx_info->tx);
 	spin_unlock_irqrestore(&bnad->bna_lock, flags);
@@ -1739,9 +1747,6 @@ bnad_cleanup_tx(struct bnad *bnad, u32 tx_id)
 	tx_info->tx = NULL;
 	tx_info->tx_id = 0;
 
-	if (0 == tx_id)
-		tasklet_kill(&bnad->tx_free_tasklet);
-
 	bnad_tx_res_free(bnad, res_info);
 }
 
@@ -1852,6 +1857,16 @@ bnad_init_rx_config(struct bnad *bnad, struct bna_rx_config *rx_config)
 	rx_config->vlan_strip_status = BNA_STATUS_T_ENABLED;
 }
 
+static void
+bnad_rx_ctrl_init(struct bnad *bnad, u32 rx_id)
+{
+	struct bnad_rx_info *rx_info = &bnad->rx_info[rx_id];
+	int i;
+
+	for (i = 0; i < bnad->num_rxp_per_rx; i++)
+		rx_info->rx_ctrl[i].bnad = bnad;
+}
+
 /* Called with mutex_lock(&bnad->conf_mutex) held */
 void
 bnad_cleanup_rx(struct bnad *bnad, u32 rx_id)
@@ -1875,8 +1890,6 @@ bnad_cleanup_rx(struct bnad *bnad, u32 rx_id)
 			del_timer_sync(&bnad->dim_timer);
 	}
 
-	bnad_napi_disable(bnad, rx_id);
-
 	init_completion(&bnad->bnad_completions.rx_comp);
 	spin_lock_irqsave(&bnad->bna_lock, flags);
 	bna_rx_disable(rx_info->rx, BNA_HARD_CLEANUP, bnad_cb_rx_disabled);
@@ -1886,6 +1899,8 @@ bnad_cleanup_rx(struct bnad *bnad, u32 rx_id)
 	if (rx_info->rx_ctrl[0].ccb->intr_type == BNA_INTR_T_MSIX)
 		bnad_rx_msix_unregister(bnad, rx_info, rx_config->num_paths);
 
+	bnad_napi_disable(bnad, rx_id);
+
 	spin_lock_irqsave(&bnad->bna_lock, flags);
 	bna_rx_destroy(rx_info->rx);
 	spin_unlock_irqrestore(&bnad->bna_lock, flags);
@@ -1939,6 +1954,8 @@ bnad_setup_rx(struct bnad *bnad, u32 rx_id)
 	if (err)
 		return err;
 
+	bnad_rx_ctrl_init(bnad, rx_id);
+
 	/* Ask BNA to create one Rx object, supplying required resources */
 	spin_lock_irqsave(&bnad->bna_lock, flags);
 	rx = bna_rx_create(&bnad->bna, bnad, rx_config, &rx_cbfn, res_info,
@@ -1948,6 +1965,12 @@ bnad_setup_rx(struct bnad *bnad, u32 rx_id)
 		goto err_return;
 	rx_info->rx = rx;
 
+	/*
+	 * Init NAPI, so that state is set to NAPI_STATE_SCHED,
+	 * so that IRQ handler cannot schedule NAPI at this point.
+	 */
+	bnad_napi_init(bnad, rx_id);
+
 	/* Register ISR for the Rx object */
 	if (intr_info->intr_type == BNA_INTR_T_MSIX) {
 		err = bnad_rx_msix_register(bnad, rx_info, rx_id,
@@ -1956,9 +1979,6 @@ bnad_setup_rx(struct bnad *bnad, u32 rx_id)
 			goto err_return;
 	}
 
-	/* Enable NAPI */
-	bnad_napi_enable(bnad, rx_id);
-
 	spin_lock_irqsave(&bnad->bna_lock, flags);
 	if (0 == rx_id) {
 		/* Set up Dynamic Interrupt Moderation Vector */
@@ -1975,6 +1995,9 @@ bnad_setup_rx(struct bnad *bnad, u32 rx_id)
 	bna_rx_enable(rx);
 	spin_unlock_irqrestore(&bnad->bna_lock, flags);
 
+	/* Enable scheduling of NAPI */
+	bnad_napi_enable(bnad, rx_id);
+
 	return 0;
 
 err_return:
drivers/net/ethernet/brocade/bna/bnad.h +1 -0
index 3c23139..60c2e9d 100644
@@ -53,6 +53,7 @@
  */
 struct bnad_rx_ctrl {
 	struct bna_ccb *ccb;
+	struct bnad *bnad;
 	unsigned long  flags;
 	struct napi_struct	napi;
 };
Signature · 1 line
1.7.1
#4 lore raw

PATCH 4/14 bna: Add Multiple Tx Queue Support

In reply to Rasesh Mody

Change details:
- Add macros bna_prio_allow, bna_default_nw_prio, bna_iscsi_prio, bna_is_iscsi_over_cee
- Added support for multipe Tx queues with a separate iSCSI Tx queue based on the default value of iSCSI port number. The feature is supported based on the underlying hardware and enabled for DCB (CEE) mode only.
- Allocate multiple TxQ resource in netdev
- Implement bnad_tx_select_queue() which enables the correct selection of TxQ Id (and tcb). This function is called either by the kernel to channel packets to the right TxQ
- bnad_tx_select_queue() returns priority, while only a few packets during transition could have wrong priority, all will be associated with a valid non-NULL tcb.
- Implement bnad_iscsi_tcb_get() and BNAD_IS_ISCSI_PKT() for iSCSI packet inspection and retrieval of tcb corresponding to the iSCSI priority.
- Construction of priority indirection table to be used by bnad to direct packets into TxQs

---
 drivers/net/ethernet/brocade/bna/bna.h  |    8 ++
 drivers/net/ethernet/brocade/bna/bnad.c |  131 ++++++++++++++++++++++++-------
 drivers/net/ethernet/brocade/bna/bnad.h |   13 +++-
 3 files changed, 121 insertions(+), 31 deletions(-)
drivers/net/ethernet/brocade/bna/bna.h +8 -0
index 2a587c5..e4f914c 100644
@@ -351,6 +351,14 @@ do {									\
 	}								\
 } while (0)
 
+#define bna_prio_allowed(_bna, _prio) ((_bna)->tx_mod.prio_map & (1 << _prio))
+
+#define bna_iscsi_prio(_bna) ((_bna)->tx_mod.iscsi_prio)
+
+#define bna_default_prio(_bna) ((_bna)->tx_mod.default_prio)
+
+#define bna_is_iscsi_over_cee(_bna) ((_bna)->tx_mod.iscsi_over_cee)
+
 /**
  *
  *  Inline functions
drivers/net/ethernet/brocade/bna/bnad.c +101 -30

240 lines not on this page · raw message

drivers/net/ethernet/brocade/bna/bnad.h +12 -1
index 60c2e9d..c8664d5 100644
@@ -40,7 +40,6 @@
 
 #define BNAD_MAX_TX		1
 #define BNAD_MAX_TXQ_PER_TX	8	/* 8 priority queues */
-#define BNAD_TXQ_NUM		1
 
 #define BNAD_MAX_RX		1
 #define BNAD_MAX_RXP_PER_RX	16
@@ -98,6 +97,9 @@ struct bnad_rx_ctrl {
 #define BNAD_RXQ_STARTED		1
 
 /* Resource limits */
+#define BNAD_MAX_TXQ			(BNAD_MAX_TX * BNAD_MAX_TXQ_PER_TX)
+#define BNAD_MAX_RXP			(BNAD_MAX_RX * BNAD_MAX_RXP_PER_RX)
+
 #define BNAD_NUM_TXQ			(bnad->num_tx * bnad->num_txq_per_tx)
 #define BNAD_NUM_RXP			(bnad->num_rx * bnad->num_rxp_per_rx)
 
@@ -231,6 +233,15 @@ struct bnad_unmap_q {
 /* Defined as bit positions */
 #define BNAD_FP_IN_RX_PATH	      0
 
+/*
+ * Deep Inspection : Checks if packet is ISCSI based on
+ * standard iSCSI port
+ */
+#define BNAD_TCP_ISCSI_PORT 3260
+#define BNAD_IS_ISCSI_PKT(_tch)				\
+(((_tch)->source == ntohs(BNAD_TCP_ISCSI_PORT)) ||	\
+	((_tch)->dest == ntohs(BNAD_TCP_ISCSI_PORT)))
+
 struct bnad {
 	struct net_device	*netdev;
 
Signature · 1 line
1.7.1
#5 lore raw

Re: [PATCH 04/14] bna: Add Multiple Tx Queue Support

Quoted 9 lines · Rasesh Mody

Change details:
- Add macros bna_prio_allow, bna_default_nw_prio, bna_iscsi_prio, bna_is_iscsi_over_cee
- Added support for multipe Tx queues with a separate iSCSI Tx queue based on the default value of iSCSI port number. The feature is supported based on the underlying hardware and enabled for DCB (CEE) mode only.
- Allocate multiple TxQ resource in netdev
- Implement bnad_tx_select_queue() which enables the correct selection of TxQ Id (and tcb). This function is called either by the kernel to channel

Quoted 8 lines

packets to the right TxQ
- bnad_tx_select_queue() returns priority, while only a few packets during transition could have wrong priority, all will be associated with a valid non-NULL tcb.
- Implement bnad_iscsi_tcb_get() and BNAD_IS_ISCSI_PKT() for iSCSI packet inspection and retrieval of tcb corresponding to the iSCSI priority.
- Construction of priority indirection table to be used by bnad to direct packets into TxQs

[...]

You probably should implement TX priority classes through the ndo_setup_tc operation, not ndo_select_queue.

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#6 lore raw

RE: [PATCH 04/14] bna: Add Multiple Tx Queue Support

Quoted 26 lines

From: Ben Hutchings [mailto:[email protected]]
Sent: Tuesday, August 16, 2011 2:49 PM

Quoted 4 lines · Rasesh Mody

Change details:
- Add macros bna_prio_allow, bna_default_nw_prio, bna_iscsi_prio, bna_is_iscsi_over_cee
- Added support for multipe Tx queues with a separate iSCSI Tx queue

based

Quoted 1 line

on the default value of iSCSI port number. The feature is supported

based

Quoted 3 lines

on the underlying hardware and enabled for DCB (CEE) mode only.
- Allocate multiple TxQ resource in netdev
- Implement bnad_tx_select_queue() which enables the correct

selection of

Quoted 1 line

TxQ Id (and tcb). This function is called either by the kernel to

channel

Quoted 2 lines

packets to the right TxQ
- bnad_tx_select_queue() returns priority, while only a few packets

during

Quoted 1 line

transition could have wrong priority, all will be associated with a

valid

Quoted 2 lines

non-NULL tcb.
- Implement bnad_iscsi_tcb_get() and BNAD_IS_ISCSI_PKT() for iSCSI

packet

Quoted 1 line

inspection and retrieval of tcb corresponding to the iSCSI

Quoted 8 lines

priority.

Quoted 1 line

- Construction of priority indirection table to be used by bnad to

direct

Quoted 1 line

packets into TxQs

[...]

You probably should implement TX priority classes through the ndo_setup_tc operation, not ndo_select_queue.

The reason we went with ndo_select_queue is due to the need for mapping iSCSI packets (TCP port 3260) to a priority derived from DCB configuration. Here the iSCSI packets may not have any tc defined in the packet header. Thanks,
Rasesh

#7 lore raw

RE: [PATCH 04/14] bna: Add Multiple Tx Queue Support

Quoted 30 lines · Rasesh Mody
Quoted 30 lines

From: Ben Hutchings [mailto:[email protected]]
Sent: Tuesday, August 16, 2011 2:49 PM

Quoted 4 lines · Rasesh Mody

Change details:
- Add macros bna_prio_allow, bna_default_nw_prio, bna_iscsi_prio, bna_is_iscsi_over_cee
- Added support for multipe Tx queues with a separate iSCSI Tx queue

based

Quoted 1 line

on the default value of iSCSI port number. The feature is supported

based

Quoted 3 lines

on the underlying hardware and enabled for DCB (CEE) mode only.
- Allocate multiple TxQ resource in netdev
- Implement bnad_tx_select_queue() which enables the correct

selection of

Quoted 1 line

TxQ Id (and tcb). This function is called either by the kernel to

channel

Quoted 2 lines

packets to the right TxQ
- bnad_tx_select_queue() returns priority, while only a few packets

during

Quoted 1 line

transition could have wrong priority, all will be associated with a

valid

Quoted 2 lines

non-NULL tcb.
- Implement bnad_iscsi_tcb_get() and BNAD_IS_ISCSI_PKT() for iSCSI

packet

Quoted 1 line

inspection and retrieval of tcb corresponding to the iSCSI

priority.

Quoted 1 line

- Construction of priority indirection table to be used by bnad to

direct

Quoted 1 line

packets into TxQs

Quoted 8 lines
Quoted 4 lines

[...]

You probably should implement TX priority classes through the ndo_setup_tc operation, not ndo_select_queue.

The reason we went with ndo_select_queue is due to the need for mapping iSCSI packets (TCP port 3260) to a priority derived from DCB configuration. Here the iSCSI packets may not have any tc defined in the packet header.

There is an skb priority, which is derived from the socket priority option (SO_PRIORITY). If you implement ndo_setup_tc then the networking core will take care of mapping the skb priority onto a different queue (or range of queues).

I don't know whether the socket priority option is easily configurable for the existing iSCSI implementations. But looking at port numbers really doesn't seem like the right way to do this.

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#8 lore raw

Re: [PATCH 04/14] bna: Add Multiple Tx Queue Support

Quoted 45 lines · Ben Hutchings
Quoted 30 lines · Rasesh Mody
Quoted 30 lines

From: Ben Hutchings [mailto:[email protected]]
Sent: Tuesday, August 16, 2011 2:49 PM

Quoted 4 lines · Rasesh Mody

Change details:
- Add macros bna_prio_allow, bna_default_nw_prio, bna_iscsi_prio, bna_is_iscsi_over_cee
- Added support for multipe Tx queues with a separate iSCSI Tx queue

based

Quoted 1 line

on the default value of iSCSI port number. The feature is supported

based

Quoted 3 lines

on the underlying hardware and enabled for DCB (CEE) mode only.
- Allocate multiple TxQ resource in netdev
- Implement bnad_tx_select_queue() which enables the correct

selection of

Quoted 1 line

TxQ Id (and tcb). This function is called either by the kernel to

channel

Quoted 2 lines

packets to the right TxQ
- bnad_tx_select_queue() returns priority, while only a few packets

during

Quoted 1 line

transition could have wrong priority, all will be associated with a

valid

Quoted 2 lines

non-NULL tcb.
- Implement bnad_iscsi_tcb_get() and BNAD_IS_ISCSI_PKT() for iSCSI

packet

Quoted 1 line

inspection and retrieval of tcb corresponding to the iSCSI

priority.

Quoted 1 line

- Construction of priority indirection table to be used by bnad to

direct

Quoted 1 line

packets into TxQs

Quoted 8 lines
Quoted 4 lines

[...]

You probably should implement TX priority classes through the ndo_setup_tc operation, not ndo_select_queue.

The reason we went with ndo_select_queue is due to the need for mapping iSCSI packets (TCP port 3260) to a priority derived from DCB configuration. Here the iSCSI packets may not have any tc defined in the packet header.

There is an skb priority, which is derived from the socket priority option (SO_PRIORITY). If you implement ndo_setup_tc then the networking core will take care of mapping the skb priority onto a different queue (or range of queues).

Quoted 6 lines

I don't know whether the socket priority option is easily configurable for the existing iSCSI implementations. But looking at port numbers really doesn't seem like the right way to do this.

Ben.

At least open-iscsi supports DCB by listening to the RTNLGRP_DCB for events. These are generated with dcbnl_cee_notify and dcbnl_ieee_notify. To support this in your driver you need to call dcb_setapp() or dcb_ieee_setapp() to add the application data and follow this with the appropriate notify call. Then assuming you do the necessary tc setup work the stack will handle the mapping of priority to queues.

John.

#9 lore raw

RE: [PATCH 04/14] bna: Add Multiple Tx Queue Support

Quoted 65 lines

From: John Fastabend [mailto:[email protected]]
Sent: Tuesday, August 16, 2011 5:18 PM

Quoted 9 lines · Ben Hutchings
Quoted 8 lines · Rasesh Mody
Quoted 8 lines

From: Ben Hutchings [mailto:[email protected]]
Sent: Tuesday, August 16, 2011 2:49 PM

Quoted 4 lines · Rasesh Mody

Change details:
- Add macros bna_prio_allow, bna_default_nw_prio, bna_iscsi_prio, bna_is_iscsi_over_cee
- Added support for multipe Tx queues with a separate iSCSI Tx

queue

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

based

Quoted 1 line

on the default value of iSCSI port number. The feature is

supported

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

based

Quoted 3 lines

on the underlying hardware and enabled for DCB (CEE) mode only.
- Allocate multiple TxQ resource in netdev
- Implement bnad_tx_select_queue() which enables the correct

selection of

Quoted 1 line

TxQ Id (and tcb). This function is called either by the kernel

to

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

channel

Quoted 2 lines

packets to the right TxQ
- bnad_tx_select_queue() returns priority, while only a few

packets

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

during

Quoted 1 line

transition could have wrong priority, all will be associated

with a

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

valid

Quoted 2 lines

non-NULL tcb.
- Implement bnad_iscsi_tcb_get() and BNAD_IS_ISCSI_PKT() for iSCSI

packet

Quoted 1 line

inspection and retrieval of tcb corresponding to the iSCSI

priority.

Quoted 1 line

- Construction of priority indirection table to be used by bnad to

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

direct

Quoted 1 line

packets into TxQs

[...]

You probably should implement TX priority classes through the ndo_setup_tc operation, not ndo_select_queue.

The reason we went with ndo_select_queue is due to the need for

mapping

Quoted 1 line
Quoted 1 line

iSCSI packets (TCP port 3260) to a priority derived from DCB

configuration.

Quoted 1 line
Quoted 1 line

Here the iSCSI packets may not have any tc defined in the packet

header.

Quoted 3 lines

There is an skb priority, which is derived from the socket priority option (SO_PRIORITY). If you implement ndo_setup_tc then the

networking

Quoted 9 lines

core will take care of mapping the skb priority onto a different queue (or range of queues).

I don't know whether the socket priority option is easily configurable for the existing iSCSI implementations. But looking at port numbers really doesn't seem like the right way to do this.

Ben.

Quoted 11 lines

At least open-iscsi supports DCB by listening to the RTNLGRP_DCB for events.
These are generated with dcbnl_cee_notify and dcbnl_ieee_notify. To support
this in your driver you need to call dcb_setapp() or dcb_ieee_setapp() to
add the application data and follow this with the appropriate notify call.
Then assuming you do the necessary tc setup work the stack will handle the
mapping of priority to queues.

This is how iSCSI over DCB feature is expected to works in BNA driver:- FW running in the BNA adapter implements the DCB protocol. It learns the iSCSI priority from the switch through iSCSI TLV exchange. BNA driver extracts the iSCSI priority from the FW that needs to be used for iSCSI packets. For every outgoing packet, BNA driver does a TCP header inspection to classify iSCSI packet and attach right 802.1q priority & send it on the correct TX queue.

This is expected to work with iSCSI applications that do not configure the priority with SO_PRIORITY - here the iSCSI priority configuration actually comes from the switch to the adapter.

The goal of this iSCSI priority is:
a) adapter applies prioritized scheduling for packets in its egress - to guarantee minimum bandwidth as per ETS
b) packets are tagged with right priority so that switch can also identify and guarantee BW on its egress.

Hope this explains.

Thanks,
Rasesh

#10 lore raw

Re: [PATCH 04/14] bna: Add Multiple Tx Queue Support

Quoted 77 lines · Rasesh Mody
Quoted 65 lines

From: John Fastabend [mailto:[email protected]]
Sent: Tuesday, August 16, 2011 5:18 PM

Quoted 9 lines · Ben Hutchings
Quoted 8 lines · Rasesh Mody
Quoted 8 lines

From: Ben Hutchings [mailto:[email protected]]
Sent: Tuesday, August 16, 2011 2:49 PM

Quoted 4 lines · Rasesh Mody

Change details:
- Add macros bna_prio_allow, bna_default_nw_prio, bna_iscsi_prio, bna_is_iscsi_over_cee
- Added support for multipe Tx queues with a separate iSCSI Tx

queue

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

based

Quoted 1 line

on the default value of iSCSI port number. The feature is

supported

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

based

Quoted 3 lines

on the underlying hardware and enabled for DCB (CEE) mode only.
- Allocate multiple TxQ resource in netdev
- Implement bnad_tx_select_queue() which enables the correct

selection of

Quoted 1 line

TxQ Id (and tcb). This function is called either by the kernel

to

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

channel

Quoted 2 lines

packets to the right TxQ
- bnad_tx_select_queue() returns priority, while only a few

packets

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

during

Quoted 1 line

transition could have wrong priority, all will be associated

with a

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

valid

Quoted 2 lines

non-NULL tcb.
- Implement bnad_iscsi_tcb_get() and BNAD_IS_ISCSI_PKT() for iSCSI

packet

Quoted 1 line

inspection and retrieval of tcb corresponding to the iSCSI

priority.

Quoted 1 line

- Construction of priority indirection table to be used by bnad to

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

direct

Quoted 1 line

packets into TxQs

[...]

You probably should implement TX priority classes through the ndo_setup_tc operation, not ndo_select_queue.

The reason we went with ndo_select_queue is due to the need for

mapping

Quoted 1 line
Quoted 1 line

iSCSI packets (TCP port 3260) to a priority derived from DCB

configuration.

Quoted 1 line
Quoted 1 line

Here the iSCSI packets may not have any tc defined in the packet

header.

Quoted 3 lines

There is an skb priority, which is derived from the socket priority option (SO_PRIORITY). If you implement ndo_setup_tc then the

networking

Quoted 9 lines

core will take care of mapping the skb priority onto a different queue (or range of queues).

I don't know whether the socket priority option is easily configurable for the existing iSCSI implementations. But looking at port numbers really doesn't seem like the right way to do this.

Ben.

Quoted 11 lines

At least open-iscsi supports DCB by listening to the RTNLGRP_DCB for events.
These are generated with dcbnl_cee_notify and dcbnl_ieee_notify. To support
this in your driver you need to call dcb_setapp() or dcb_ieee_setapp() to
add the application data and follow this with the appropriate notify call.
Then assuming you do the necessary tc setup work the stack will handle the
mapping of priority to queues.

Quoted 5 lines

This is how iSCSI over DCB feature is expected to works in BNA driver:- FW running in the BNA adapter implements the DCB protocol. It learns the iSCSI priority from the switch through iSCSI TLV exchange. BNA driver extracts the iSCSI priority from the FW that needs to be used for iSCSI packets.

Up to here this is fine. What I was suggesting was to then use the dcb_setapp() routines to program the iSCSI TLV and generate an event so any user space applications listening to DCB events could handle this. It would also be nice if your driver notified user space of any PG or PFC changes as well. Then management agents (lldpad) could use the DCB attributes to make policy decisions.

Quoted 8 lines

For every outgoing packet, BNA driver does a TCP header inspection to classify iSCSI packet and attach right 802.1q priority & send it on the correct TX queue.

This is expected to work with iSCSI applications that do not configure the priority with SO_PRIORITY - here the iSCSI priority configuration actually comes from the switch to the adapter.

Although this works I don't think it is optimal for a few reason. Your L2 driver is inspecting TCP frames which is bad layering IMHO. The iSCSI port number is hard coded into the driver so it will only work with the well known port number. Also it adds more driver specific behavior into select_queue() where I think the trend is to try to use select_queue() less not more.

To address iSCSI applications that do not configure the priority we could either work on adding the DCB hooks needed in those applications. Or look at adding a hook in the qdisc layer to to do what your select_queue() hook does here. I started prototyping this awhile ago but this requires running the packet classifiers and associated actions before picking a queue assuming you want to use mq or mqprio. I hope to get back to this soon I have some more details to flush out wrt this and need to run it by some other folks to make sure its a sane idea.

Quoted 5 lines

The goal of this iSCSI priority is:
a) adapter applies prioritized scheduling for packets in its egress - to guarantee minimum bandwidth as per ETS
b) packets are tagged with right priority so that switch can also identify and guarantee BW on its egress.

Correct. This is the same for other drivers that support DCB and use tc_setup as Ben suggested. See the bnx2x driver for an example that also uses a FW based LLDP engine and does this.

Quoted 2 lines

Hope this explains.

I think the one valid item is the unsupported applications but hopefully that can be addressed. Thanks for the details.

John.

Quoted 3 lines

Thanks,
Rasesh

#11 lore raw

RE: [PATCH 04/14] bna: Add Multiple Tx Queue Support

Quoted 147 lines

From: John Fastabend [mailto:[email protected]]
Sent: Tuesday, August 16, 2011 10:48 PM

Quoted 11 lines · Rasesh Mody
Quoted 11 lines

From: John Fastabend [mailto:[email protected]]
Sent: Tuesday, August 16, 2011 5:18 PM

Quoted 7 lines · Ben Hutchings
Quoted 6 lines · Rasesh Mody
Quoted 6 lines

From: Ben Hutchings [mailto:[email protected]]
Sent: Tuesday, August 16, 2011 2:49 PM

Quoted 2 lines · Rasesh Mody

Change details:
- Add macros bna_prio_allow, bna_default_nw_prio,

bna_iscsi_prio,

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

bna_is_iscsi_over_cee
- Added support for multipe Tx queues with a separate iSCSI Tx

queue

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

based

Quoted 1 line

on the default value of iSCSI port number. The feature is

supported

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

based

Quoted 1 line

on the underlying hardware and enabled for DCB (CEE) mode

only.

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

- Allocate multiple TxQ resource in netdev
- Implement bnad_tx_select_queue() which enables the correct

selection of

Quoted 1 line

TxQ Id (and tcb). This function is called either by the kernel

to

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

channel

Quoted 2 lines

packets to the right TxQ
- bnad_tx_select_queue() returns priority, while only a few

Quoted 7 lines
Quoted 7 lines

packets

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

during

Quoted 1 line

transition could have wrong priority, all will be associated

with a

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

valid

Quoted 2 lines

non-NULL tcb.
- Implement bnad_iscsi_tcb_get() and BNAD_IS_ISCSI_PKT() for

iSCSI

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

packet

Quoted 1 line

inspection and retrieval of tcb corresponding to the iSCSI

priority.

Quoted 1 line

- Construction of priority indirection table to be used by bnad

to

Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

direct

Quoted 1 line

packets into TxQs

[...]

You probably should implement TX priority classes through the ndo_setup_tc operation, not ndo_select_queue.

The reason we went with ndo_select_queue is due to the need for

mapping

Quoted 1 line
Quoted 1 line

iSCSI packets (TCP port 3260) to a priority derived from DCB

Quoted 8 lines
Quoted 8 lines

configuration.

Quoted 1 line
Quoted 1 line

Here the iSCSI packets may not have any tc defined in the packet

header.

Quoted 3 lines

There is an skb priority, which is derived from the socket priority option (SO_PRIORITY). If you implement ndo_setup_tc then the

networking

Quoted 1 line

core will take care of mapping the skb priority onto a different

queue

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

(or range of queues).

I don't know whether the socket priority option is easily

configurable

Quoted 11 lines
Quoted 11 lines
Quoted 5 lines

for the existing iSCSI implementations. But looking at port numbers really doesn't seem like the right way to do this.

Ben.

At least open-iscsi supports DCB by listening to the RTNLGRP_DCB for events.
These are generated with dcbnl_cee_notify and dcbnl_ieee_notify. To support
this in your driver you need to call dcb_setapp() or

dcb_ieee_setapp()

Quoted 4 lines
Quoted 4 lines

to
add the application data and follow this with the appropriate notify call.
Then assuming you do the necessary tc setup work the stack will

handle

Quoted 4 lines
Quoted 2 lines

the
mapping of priority to queues.

This is how iSCSI over DCB feature is expected to works in BNA

driver:-

Quoted 1 line

FW running in the BNA adapter implements the DCB protocol. It learns

the

Quoted 2 lines

iSCSI priority from the switch through iSCSI TLV exchange. BNA driver extracts the iSCSI priority from the FW that needs to be used for

iSCSI

Quoted 1 line

packets.

Up to here this is fine. What I was suggesting was to then use the dcb_setapp() routines to program the iSCSI TLV and generate an event so any user space applications listening to DCB events could handle this. It would also be nice if your driver notified user space of any PG or PFC changes as well. Then management agents (lldpad) could use the DCB attributes to make policy decisions.

Quoted 5 lines

For every outgoing packet, BNA driver does a TCP header inspection to classify iSCSI packet and attach right 802.1q priority & send it on the correct TX queue.

This is expected to work with iSCSI applications that do not configure

the

Quoted 1 line

priority with SO_PRIORITY - here the iSCSI priority configuration

actually

Quoted 2 lines

comes from the switch to the adapter.

Although this works I don't think it is optimal for a few reason. Your L2 driver is inspecting TCP frames which is bad layering IMHO. The iSCSI port number is hard coded into the driver so it will only work with the well known port number. Also it adds more driver specific behavior into select_queue() where I think the trend is to try to use select_queue() less not more.

To address iSCSI applications that do not configure the priority we could either work on adding the DCB hooks needed in those applications. Or look at adding a hook in the qdisc layer to to do what your select_queue() hook does here. I started prototyping this awhile ago but this requires running the packet classifiers and associated actions before picking a queue assuming you want to use mq or mqprio. I hope to get back to this soon I have some more details to flush out wrt this and need to run it by some other folks to make sure its a sane idea.

Quoted 2 lines

The goal of this iSCSI priority is:
a) adapter applies prioritized scheduling for packets in its egress -

to

Quoted 2 lines

guarantee minimum bandwidth as per ETS
b) packets are tagged with right priority so that switch can also

identify

Quoted 1 line

and guarantee BW on its egress.

Correct. This is the same for other drivers that support DCB and use tc_setup as Ben suggested. See the bnx2x driver for an example that also uses a FW based LLDP engine and does this.

Quoted 1 line
Quoted 4 lines
Quoted 1 line

Hope this explains.

I think the one valid item is the unsupported applications but hopefully that can be addressed. Thanks for the details.

Can we go with this approach of select_queue() for now till we have DCB hooks added to the iSCSI applications or the qdisc layer? We will address this to use setup_tc() as the framework becomes available.

Thanks,
Rasesh

#12 lore raw

PATCH 5/14 bna: SKB Check and Drop Macros

In reply to Rasesh Mody

Add macros to check and drop skb from transmit path and return.

---
 drivers/net/ethernet/brocade/bna/bnad.c |   68 +++++++++++++++++-------------
 drivers/net/ethernet/brocade/bna/bnad.h |    2 +
 2 files changed, 40 insertions(+), 30 deletions(-)
drivers/net/ethernet/brocade/bna/bnad.c +38 -30
index 895f18b..64e2106 100644
@@ -74,6 +74,36 @@ do {								\
 
 #define BNAD_TXRX_SYNC_MDELAY	250	/* 250 msecs */
 
+#define BNAD_DROP_AND_RETURN(_counter)	\
+{ \
+	dev_kfree_skb(skb); \
+	BNAD_UPDATE_CTR(bnad, _counter); \
+	return NETDEV_TX_OK; \
+}
+
+#define BNAD_DROP_AND_RETURN_IF(_condition, _counter)	\
+if (unlikely(_condition)) { \
+	BNAD_DROP_AND_RETURN(_counter); \
+}
+
+#define BNAD_PCI_UNMAP_SKB(_pdev, _array, _index, _depth, _skb, _frag) \
+{ \
+	int j; \
+	(_array)[_index].skb = NULL; \
+	dma_unmap_single(_pdev, dma_unmap_addr(&(_array)[_index], dma_addr), \
+			skb_headlen(_skb), DMA_TO_DEVICE); \
+	dma_unmap_addr_set(&(_array)[_index], dma_addr, 0); \
+	BNA_QE_INDX_ADD(_index, 1, _depth); \
+	for (j = 0; j < (_frag); j++) { \
+		prefetch(&(_array)[(_index) + 1]); \
+		dma_unmap_page(_pdev, dma_unmap_addr(&(_array)[_index], \
+						     dma_addr), \
+			  skb_shinfo(_skb)->frags[j].size, DMA_TO_DEVICE); \
+		dma_unmap_addr_set(&(_array)[_index], dma_addr, 0); \
+		BNA_QE_INDX_ADD(_index, 1, _depth); \
+	} \
+}
+
 /*
  * Reinitialize completions in CQ, once Rx is taken down
  */
@@ -169,7 +199,6 @@ bnad_free_txbufs(struct bnad *bnad,
 	struct bnad_unmap_q *unmap_q = tcb->unmap_q;
 	struct bnad_skb_unmap *unmap_array;
 	struct sk_buff		*skb;
-	int i;
 
 	/*
 	 * Just return if TX is stopped. This check is useful
@@ -195,32 +224,14 @@ bnad_free_txbufs(struct bnad *bnad,
 	while (wis) {
 		skb = unmap_array[unmap_cons].skb;
 
-		unmap_array[unmap_cons].skb = NULL;
-
 		sent_packets++;
 		sent_bytes += skb->len;
 		wis -= BNA_TXQ_WI_NEEDED(1 + skb_shinfo(skb)->nr_frags);
 
-		dma_unmap_single(&bnad->pcidev->dev,
-				 dma_unmap_addr(&unmap_array[unmap_cons],
-						dma_addr), skb_headlen(skb),
-				 DMA_TO_DEVICE);
-		dma_unmap_addr_set(&unmap_array[unmap_cons], dma_addr, 0);
-		BNA_QE_INDX_ADD(unmap_cons, 1, unmap_q->q_depth);
-
-		prefetch(&unmap_array[unmap_cons + 1]);
-		for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
-			prefetch(&unmap_array[unmap_cons + 1]);
+		BNAD_PCI_UNMAP_SKB(&bnad->pcidev->dev, unmap_array, unmap_cons,
+				   unmap_q->q_depth, skb,
+				   skb_shinfo(skb)->nr_frags);
 
-			dma_unmap_page(&bnad->pcidev->dev,
-				       dma_unmap_addr(&unmap_array[unmap_cons],
-						      dma_addr),
-				       skb_shinfo(skb)->frags[i].size,
-				       DMA_TO_DEVICE);
-			dma_unmap_addr_set(&unmap_array[unmap_cons], dma_addr,
-					   0);
-			BNA_QE_INDX_ADD(unmap_cons, 1, unmap_q->q_depth);
-		}
 		dev_kfree_skb_any(skb);
 	}
 
@@ -2585,16 +2596,13 @@ bnad_start_xmit(struct sk_buff *skb, struct net_device *netdev)
 	 * Takes care of the Tx that is scheduled between clearing the flag
 	 * and the netif_stop_all_queue() call.
 	 */
-	if (unlikely(!test_bit(BNAD_TXQ_TX_STARTED, &tcb->flags))) {
-		dev_kfree_skb(skb);
-		return NETDEV_TX_OK;
-	}
+	BNAD_DROP_AND_RETURN_IF(!test_bit(BNAD_TXQ_TX_STARTED, &tcb->flags),
+				tx_skb_stopping);
 
 	vectors = 1 + skb_shinfo(skb)->nr_frags;
-	if (vectors > BFI_TX_MAX_VECTORS_PER_PKT) {
-		dev_kfree_skb(skb);
-		return NETDEV_TX_OK;
-	}
+	BNAD_DROP_AND_RETURN_IF(vectors > BFI_TX_MAX_VECTORS_PER_PKT,
+				tx_skb_max_vectors);
+
 	wis = BNA_TXQ_WI_NEEDED(vectors);	/* 4 vectors per work item */
 	acked = 0;
 	if (unlikely(wis > BNA_QE_FREE_CNT(tcb, tcb->q_depth) ||
drivers/net/ethernet/brocade/bna/bnad.h +2 -0
index c8664d5..6074c6d 100644
@@ -150,6 +150,8 @@ struct bnad_drv_stats {
 	u64		udpcsum_offload;
 	u64		csum_help;
 	u64		csum_help_err;
+	u64		tx_skb_stopping;
+	u64		tx_skb_max_vectors;
 
 	u64		hw_stats_updates;
 	u64		netif_rx_schedule;
Signature · 1 line
1.7.1
#13 lore raw

PATCH 6/14 bna: TX Path and RX Path Changes

In reply to Rasesh Mody

Change details:
- Disable and enable interrupts from the same polling context to prevent reordering in Rx path.
- Add Rx NAPI debug counters.
- Make NAPI budget check more generic
- Add a macro bnad_dim_timer_stop for DIM(Dynamic Interrupt Moderation) timer stop
- Handle reduced MSI-X vectors case in bnad_enable_msix
- Replace existing checks with macros and add more checks for illegal skbs in transmit path. Add more tx_skb counters for dropped skbs.
- Check for single frame TSO skbs and send them out as non-TSO.
- Put memory barrier after bna_txq_prod_indx_doorbell()

---
 drivers/net/ethernet/brocade/bna/bnad.c |  207 +++++++++++++++++--------------
 drivers/net/ethernet/brocade/bna/bnad.h |   33 +++++-
 2 files changed, 148 insertions(+), 92 deletions(-)
drivers/net/ethernet/brocade/bna/bnad.c +116 -91
index 64e2106..0faa8a1 100644
@@ -532,7 +532,7 @@ bnad_poll_cq(struct bnad *bnad, struct bna_ccb *ccb, int budget)
 		      (flags & BNA_CQ_EF_L4_CKSUM_OK)))
 			skb->ip_summed = CHECKSUM_UNNECESSARY;
 		else
-			skb_checksum_none_assert(skb);
+			skb->ip_summed = CHECKSUM_NONE;
 
 		rcb->rxq->rx_packets++;
 		rcb->rxq->rx_bytes += skb->len;
@@ -555,7 +555,8 @@ next:
 	BNA_QE_INDX_ADD(ccb->producer_index, wis, ccb->q_depth);
 
 	if (likely(test_bit(BNAD_RXQ_STARTED, &ccb->rcb[0]->flags)))
-		bna_ib_ack(ccb->i_dbell, packets);
+		bna_ib_ack_disable_irq(ccb->i_dbell, packets);
+
 	bnad_refill_rxq(bnad, ccb->rcb[0]);
 	if (ccb->rcb[1])
 		bnad_refill_rxq(bnad, ccb->rcb[1]);
@@ -593,10 +594,9 @@ bnad_netif_rx_schedule_poll(struct bnad *bnad, struct bna_ccb *ccb)
 	struct napi_struct *napi = &rx_ctrl->napi;
 
 	if (likely(napi_schedule_prep(napi))) {
-		bnad_disable_rx_irq(bnad, ccb);
 		__napi_schedule(napi);
+		rx_ctrl->rx_schedule++;
 	}
-	BNAD_UPDATE_CTR(bnad, netif_rx_schedule);
 }
 
 /* MSIX Rx Path Handler */
@@ -605,8 +605,10 @@ bnad_msix_rx(int irq, void *data)
 {
 	struct bna_ccb *ccb = (struct bna_ccb *)data;
 
-	if (ccb)
+	if (ccb) {
+		((struct bnad_rx_ctrl *)(ccb->ctrl))->rx_intr_ctr++;
 		bnad_netif_rx_schedule_poll(ccb->bnad, ccb);
+	}
 
 	return IRQ_HANDLED;
 }
@@ -1675,22 +1677,23 @@ bnad_napi_poll_rx(struct napi_struct *napi, int budget)
 	struct bnad *bnad = rx_ctrl->bnad;
 	int rcvd = 0;
 
+	rx_ctrl->rx_poll_ctr++;
 
 	if (!netif_carrier_ok(bnad->netdev))
 		goto poll_exit;
 
 	rcvd = bnad_poll_cq(bnad, rx_ctrl->ccb, budget);
-	if (rcvd == budget)
+	if (rcvd >= budget)
 		return rcvd;
 
 poll_exit:
 	napi_complete((napi));
 
-	BNAD_UPDATE_CTR(bnad, netif_rx_complete);
-
+	rx_ctrl->rx_complete++;
 
 	if (rx_ctrl->ccb)
-		bnad_enable_rx_irq(bnad, rx_ctrl->ccb);
+		bnad_enable_rx_irq_unsafe(rx_ctrl->ccb);
+
 	return rcvd;
 }
 
@@ -1894,20 +1897,14 @@ bnad_cleanup_rx(struct bnad *bnad, u32 rx_id)
 	struct bna_rx_config *rx_config = &bnad->rx_config[rx_id];
 	struct bna_res_info *res_info = &bnad->rx_res_info[rx_id].res_info[0];
 	unsigned long flags;
-	int dim_timer_del = 0;
 
 	if (!rx_info->rx)
 		return;
 
-	if (0 == rx_id) {
-		spin_lock_irqsave(&bnad->bna_lock, flags);
-		dim_timer_del = bnad_dim_timer_running(bnad);
-		if (dim_timer_del)
-			clear_bit(BNAD_RF_DIM_TIMER_RUNNING, &bnad->run_flags);
-		spin_unlock_irqrestore(&bnad->bna_lock, flags);
-		if (dim_timer_del)
-			del_timer_sync(&bnad->dim_timer);
-	}
+	spin_lock_irqsave(&bnad->bna_lock, flags);
+	if (0 == rx_id)
+		bnad_dim_timer_stop(bnad, flags);
+	spin_unlock_irqrestore(&bnad->bna_lock, flags);
 
 	init_completion(&bnad->bnad_completions.rx_comp);
 	spin_lock_irqsave(&bnad->bna_lock, flags);
@@ -2408,12 +2405,11 @@ bnad_enable_msix(struct bnad *bnad)
 
 		spin_lock_irqsave(&bnad->bna_lock, flags);
 		/* ret = #of vectors that we got */
-		bnad_q_num_adjust(bnad, ret, 0);
+		bnad_q_num_adjust(bnad, (ret - BNAD_MAILBOX_MSIX_VECTORS) / 2,
+			(ret - BNAD_MAILBOX_MSIX_VECTORS) / 2);
 		spin_unlock_irqrestore(&bnad->bna_lock, flags);
 
-		bnad->msix_num = (bnad->num_tx * bnad->num_txq_per_tx)
-			+ (bnad->num_rx
-			* bnad->num_rxp_per_rx) +
+		bnad->msix_num = BNAD_NUM_TXQ + BNAD_NUM_RXP +
 			 BNAD_MAILBOX_MSIX_VECTORS;
 
 		if (bnad->msix_num > ret)
@@ -2571,26 +2567,21 @@ bnad_start_xmit(struct sk_buff *skb, struct net_device *netdev)
 	u32		unmap_prod, wis, wis_used, wi_range;
 	u32		vectors, vect_id, i, acked;
 	int			err;
+	unsigned int		len;
 
 	dma_addr_t		dma_addr;
 	struct bna_txq_entry *txqent;
 	u16	flags;
 
-	if (unlikely
-	    (skb->len <= ETH_HLEN || skb->len > BFI_TX_MAX_DATA_PER_PKT)) {
-		dev_kfree_skb(skb);
-		return NETDEV_TX_OK;
-	}
+	BNAD_DROP_AND_RETURN_IF(skb->len <= ETH_HLEN, tx_skb_too_short);
+	BNAD_DROP_AND_RETURN_IF(skb_headlen(skb) > BFI_TX_MAX_DATA_PER_VECTOR,
+				tx_skb_headlen_too_long);
+	BNAD_DROP_AND_RETURN_IF(skb_headlen(skb) == 0, tx_skb_headlen_zero);
 
 	txq_id = skb_get_queue_mapping(skb);
 
 	tcb = bnad->tx_info[0].tcb[txq_id];
 
-	if (unlikely(!tcb)) {
-		dev_kfree_skb(skb);
-		return NETDEV_TX_OK;
-	}
-
 	unmap_q = tcb->unmap_q;
 	/*
 	 * Takes care of the Tx that is scheduled between clearing the flag
@@ -2638,8 +2629,6 @@ bnad_start_xmit(struct sk_buff *skb, struct net_device *netdev)
 	}
 
 	unmap_prod = unmap_q->producer_index;
-	wis_used = 1;
-	vect_id = 0;
 	flags = 0;
 
 	txq_prod = tcb->producer_index;
@@ -2647,9 +2636,6 @@ bnad_start_xmit(struct sk_buff *skb, struct net_device *netdev)
 	BUG_ON(!(wi_range <= tcb->q_depth));
 	txqent->hdr.wi.reserved = 0;
 	txqent->hdr.wi.num_vectors = vectors;
-	txqent->hdr.wi.opcode =
-		htons((skb_is_gso(skb) ? BNA_TXQ_WI_SEND_LSO :
-		       BNA_TXQ_WI_SEND));
 
 	if (vlan_tx_tag_present(skb)) {
 		vlan_tag = (u16) vlan_tx_tag_get(skb);
@@ -2665,62 +2651,74 @@ bnad_start_xmit(struct sk_buff *skb, struct net_device *netdev)
 	txqent->hdr.wi.vlan_tag = htons(vlan_tag);
 
 	if (skb_is_gso(skb)) {
-		err = bnad_tso_prepare(bnad, skb);
-		if (err) {
-			dev_kfree_skb(skb);
-			return NETDEV_TX_OK;
+		BNAD_DROP_AND_RETURN_IF(skb_is_gso(skb) > netdev->mtu,
+					tx_skb_mss_too_long);
+		if (unlikely((skb_is_gso(skb) + skb_transport_offset(skb) +
+			      tcp_hdrlen(skb)) >= skb->len)) {
+			txqent->hdr.wi.opcode =
+				__constant_htons(BNA_TXQ_WI_SEND);
+			txqent->hdr.wi.lso_mss = 0;
+			BNAD_UPDATE_CTR(bnad, tx_skb_tso_too_short);
+		} else {
+			txqent->hdr.wi.opcode =
+				__constant_htons(BNA_TXQ_WI_SEND_LSO);
+			txqent->hdr.wi.lso_mss = htons(skb_is_gso(skb));
 		}
-		txqent->hdr.wi.lso_mss = htons(skb_is_gso(skb));
+
+		err = bnad_tso_prepare(bnad, skb);
+		BNAD_DROP_AND_RETURN_IF(err, tx_skb_tso_prepare);
 		flags |= (BNA_TXQ_WI_CF_IP_CKSUM | BNA_TXQ_WI_CF_TCP_CKSUM);
 		txqent->hdr.wi.l4_hdr_size_n_offset =
 			htons(BNA_TXQ_WI_L4_HDR_N_OFFSET
 			      (tcp_hdrlen(skb) >> 2,
 			       skb_transport_offset(skb)));
-	} else if (skb->ip_summed == CHECKSUM_PARTIAL) {
-		u8 proto = 0;
-
+	} else {
+		txqent->hdr.wi.opcode =	__constant_htons(BNA_TXQ_WI_SEND);
 		txqent->hdr.wi.lso_mss = 0;
 
-		if (skb->protocol == htons(ETH_P_IP))
-			proto = ip_hdr(skb)->protocol;
-		else if (skb->protocol == htons(ETH_P_IPV6)) {
-			/* nexthdr may not be TCP immediately. */
-			proto = ipv6_hdr(skb)->nexthdr;
-		}
-		if (proto == IPPROTO_TCP) {
-			flags |= BNA_TXQ_WI_CF_TCP_CKSUM;
-			txqent->hdr.wi.l4_hdr_size_n_offset =
-				htons(BNA_TXQ_WI_L4_HDR_N_OFFSET
-				      (0, skb_transport_offset(skb)));
-
-			BNAD_UPDATE_CTR(bnad, tcpcsum_offload);
-
-			BUG_ON(!(skb_headlen(skb) >=
-				skb_transport_offset(skb) + tcp_hdrlen(skb)));
+		BNAD_DROP_AND_RETURN_IF(skb->len > (netdev->mtu + ETH_HLEN),
+					tx_skb_non_tso_too_long);
 
-		} else if (proto == IPPROTO_UDP) {
-			flags |= BNA_TXQ_WI_CF_UDP_CKSUM;
-			txqent->hdr.wi.l4_hdr_size_n_offset =
-				htons(BNA_TXQ_WI_L4_HDR_N_OFFSET
-				      (0, skb_transport_offset(skb)));
+		if (skb->ip_summed == CHECKSUM_PARTIAL) {
+			u8 proto = 0;
 
-			BNAD_UPDATE_CTR(bnad, udpcsum_offload);
-
-			BUG_ON(!(skb_headlen(skb) >=
-				   skb_transport_offset(skb) +
-				   sizeof(struct udphdr)));
-		} else {
-			err = skb_checksum_help(skb);
-			BNAD_UPDATE_CTR(bnad, csum_help);
-			if (err) {
-				dev_kfree_skb(skb);
-				BNAD_UPDATE_CTR(bnad, csum_help_err);
-				return NETDEV_TX_OK;
+			if (skb->protocol == __constant_htons(ETH_P_IP))
+				proto = ip_hdr(skb)->protocol;
+			else if (skb->protocol ==
+				 __constant_htons(ETH_P_IPV6)) {
+				/* nexthdr may not be TCP immediately. */
+				proto = ipv6_hdr(skb)->nexthdr;
+			}
+			if (proto == IPPROTO_TCP) {
+				flags |= BNA_TXQ_WI_CF_TCP_CKSUM;
+				txqent->hdr.wi.l4_hdr_size_n_offset =
+					htons(BNA_TXQ_WI_L4_HDR_N_OFFSET
+					      (0, skb_transport_offset(skb)));
+
+				BNAD_UPDATE_CTR(bnad, tcpcsum_offload);
+
+				BNAD_DROP_AND_RETURN_IF(skb_headlen(skb) <
+					    skb_transport_offset(skb) +
+					    tcp_hdrlen(skb), tx_skb_tcp_hdr);
+
+			} else if (proto == IPPROTO_UDP) {
+				flags |= BNA_TXQ_WI_CF_UDP_CKSUM;
+				txqent->hdr.wi.l4_hdr_size_n_offset =
+					htons(BNA_TXQ_WI_L4_HDR_N_OFFSET
+					      (0, skb_transport_offset(skb)));
+
+				BNAD_UPDATE_CTR(bnad, udpcsum_offload);
+				BNAD_DROP_AND_RETURN_IF(skb_headlen(skb) <
+					    skb_transport_offset(skb) +
+					    sizeof(struct udphdr),
+							tx_skb_udp_hdr);
+
+			} else {
+				BNAD_DROP_AND_RETURN(tx_skb_csum_err);
 			}
+		} else {
+			txqent->hdr.wi.l4_hdr_size_n_offset = 0;
 		}
-	} else {
-		txqent->hdr.wi.lso_mss = 0;
-		txqent->hdr.wi.l4_hdr_size_n_offset = 0;
 	}
 
 	txqent->hdr.wi.flags = htons(flags);
@@ -2728,20 +2726,36 @@ bnad_start_xmit(struct sk_buff *skb, struct net_device *netdev)
 	txqent->hdr.wi.frame_length = htonl(skb->len);
 
 	unmap_q->unmap_array[unmap_prod].skb = skb;
-	BUG_ON(!(skb_headlen(skb) <= BFI_TX_MAX_DATA_PER_VECTOR));
-	txqent->vector[vect_id].length = htons(skb_headlen(skb));
+	len = skb_headlen(skb);
+	txqent->vector[0].length = htons(len);
 	dma_addr = dma_map_single(&bnad->pcidev->dev, skb->data,
 				  skb_headlen(skb), DMA_TO_DEVICE);
 	dma_unmap_addr_set(&unmap_q->unmap_array[unmap_prod], dma_addr,
 			   dma_addr);
 
-	BNA_SET_DMA_ADDR(dma_addr, &txqent->vector[vect_id].host_addr);
+	BNA_SET_DMA_ADDR(dma_addr, &txqent->vector[0].host_addr);
 	BNA_QE_INDX_ADD(unmap_prod, 1, unmap_q->q_depth);
 
+	vect_id = 0;
+	wis_used = 1;
+
 	for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
 		struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i];
 		u16		size = frag->size;
 
+		if (unlikely(size == 0)) {
+			unmap_prod = unmap_q->producer_index;
+			prefetch(&unmap_q->unmap_array[unmap_prod + 1]);
+
+			BNAD_PCI_UNMAP_SKB(&bnad->pcidev->dev,
+					   unmap_q->unmap_array,
+					   unmap_prod, unmap_q->q_depth, skb,
+					   i);
+			BNAD_DROP_AND_RETURN(tx_skb_frag_zero);
+		}
+
+		len += size;
+
 		if (++vect_id == BFI_TX_MAX_VECTORS_PER_WI) {
 			vect_id = 0;
 			if (--wi_range)
@@ -2752,10 +2766,10 @@ bnad_start_xmit(struct sk_buff *skb, struct net_device *netdev)
 				wis_used = 0;
 				BNA_TXQ_QPGE_PTR_GET(txq_prod, tcb->sw_qpt,
 						     txqent, wi_range);
-				BUG_ON(!(wi_range <= tcb->q_depth));
 			}
 			wis_used++;
-			txqent->hdr.wi_ext.opcode = htons(BNA_TXQ_WI_EXTENSION);
+			txqent->hdr.wi_ext.opcode =
+				__constant_htons(BNA_TXQ_WI_EXTENSION);
 		}
 
 		BUG_ON(!(size <= BFI_TX_MAX_DATA_PER_VECTOR));
@@ -2768,6 +2782,16 @@ bnad_start_xmit(struct sk_buff *skb, struct net_device *netdev)
 		BNA_QE_INDX_ADD(unmap_prod, 1, unmap_q->q_depth);
 	}
 
+	if (unlikely(len != skb->len)) {
+		unmap_prod = unmap_q->producer_index;
+		prefetch(&unmap_q->unmap_array[unmap_prod + 1]);
+
+		BNAD_PCI_UNMAP_SKB(&bnad->pcidev->dev, unmap_q->unmap_array,
+				   unmap_prod, unmap_q->q_depth, skb,
+				   skb_shinfo(skb)->nr_frags);
+		BNAD_DROP_AND_RETURN(tx_skb_len_mismatch);
+	}
+
 	unmap_q->producer_index = unmap_prod;
 	BNA_QE_INDX_ADD(txq_prod, wis_used, tcb->q_depth);
 	tcb->producer_index = txq_prod;
@@ -2778,6 +2802,7 @@ bnad_start_xmit(struct sk_buff *skb, struct net_device *netdev)
 		return NETDEV_TX_OK;
 
 	bna_txq_prod_indx_doorbell(tcb);
+	smp_mb();
 
 	if ((u16) (*tcb->hw_consumer_index) != tcb->consumer_index)
 		tasklet_schedule(&bnad->tx_free_tasklet);
@@ -2888,6 +2913,9 @@ bnad_set_rx_mode(struct net_device *netdev)
 		}
 	}
 
+	if (bnad->rx_info[0].rx == NULL)
+		goto unlock;
+
 	bna_rx_mode_set(bnad->rx_info[0].rx, new_mask, valid_mask, NULL);
 
 	if (!netdev_mc_empty(netdev)) {
@@ -3040,12 +3068,9 @@ bnad_netpoll(struct net_device *netdev)
 				continue;
 			for (j = 0; j < bnad->num_rxp_per_rx; j++) {
 				rx_ctrl = &rx_info->rx_ctrl[j];
-				if (rx_ctrl->ccb) {
-					bnad_disable_rx_irq(bnad,
-							    rx_ctrl->ccb);
+				if (rx_ctrl->ccb)
 					bnad_netif_rx_schedule_poll(bnad,
 							    rx_ctrl->ccb);
-				}
 			}
 		}
 	}
drivers/net/ethernet/brocade/bna/bnad.h +32 -1
index 6074c6d..f402149 100644
@@ -55,6 +55,11 @@ struct bnad_rx_ctrl {
 	struct bnad *bnad;
 	unsigned long  flags;
 	struct napi_struct	napi;
+	u64		rx_intr_ctr;
+	u64		rx_poll_ctr;
+	u64		rx_schedule;
+	u64		rx_keep_poll;
+	u64		rx_complete;
 };
 
 #define BNAD_RXMODE_PROMISC_DEFAULT	BNA_RXMODE_PROMISC
@@ -150,8 +155,20 @@ struct bnad_drv_stats {
 	u64		udpcsum_offload;
 	u64		csum_help;
 	u64		csum_help_err;
+	u64		tx_skb_too_short;
 	u64		tx_skb_stopping;
 	u64		tx_skb_max_vectors;
+	u64		tx_skb_mss_too_long;
+	u64		tx_skb_tso_too_short;
+	u64		tx_skb_tso_prepare;
+	u64		tx_skb_non_tso_too_long;
+	u64		tx_skb_tcp_hdr;
+	u64		tx_skb_udp_hdr;
+	u64		tx_skb_csum_err;
+	u64		tx_skb_headlen_too_long;
+	u64		tx_skb_headlen_zero;
+	u64		tx_skb_frag_zero;
+	u64		tx_skb_len_mismatch;
 
 	u64		hw_stats_updates;
 	u64		netif_rx_schedule;
@@ -359,7 +376,7 @@ extern void bnad_netdev_hwstats_fill(struct bnad *bnad,
 
 #define bnad_enable_rx_irq_unsafe(_ccb)			\
 {							\
-	if (likely(test_bit(BNAD_RXQ_STARTED, &ccb->rcb[0]->flags))) {\
+	if (likely(test_bit(BNAD_RXQ_STARTED, &(_ccb)->rcb[0]->flags))) {\
 		bna_ib_coalescing_timer_set((_ccb)->i_dbell,	\
 			(_ccb)->rx_coalescing_timeo);		\
 		bna_ib_ack((_ccb)->i_dbell, 0);			\
@@ -369,5 +386,19 @@ extern void bnad_netdev_hwstats_fill(struct bnad *bnad,
 #define bnad_dim_timer_running(_bnad)				\
 	(((_bnad)->cfg_flags & BNAD_CF_DIM_ENABLED) &&		\
 	(test_bit(BNAD_RF_DIM_TIMER_RUNNING, &((_bnad)->run_flags))))
+#define bnad_dim_timer_stop(_bnad, _flags)		\
+do {							\
+	int to_del = 0;					\
+							\
+	if ((_bnad)->cfg_flags & BNAD_CF_DIM_ENABLED &&	\
+	    test_bit(BNAD_RF_DIM_TIMER_RUNNING, &(_bnad)->run_flags)) {\
+		clear_bit(BNAD_RF_DIM_TIMER_RUNNING, &(_bnad)->run_flags);\
+		to_del = 1;				\
+	}						\
+	spin_unlock_irqrestore(&(_bnad)->bna_lock, (_flags));	\
+	if (to_del)					\
+		del_timer_sync(&(_bnad)->dim_timer);	\
+	spin_lock_irqsave(&(_bnad)->bna_lock, (_flags));\
+} while (0)
 
 #endif /* __BNAD_H__ */
Signature · 1 line
1.7.1
#14 lore raw

Re: [PATCH 06/14] bna: TX Path and RX Path Changes

Quoted 25 lines · Rasesh Mody

Change details:
- Disable and enable interrupts from the same polling context to prevent reordering in Rx path.
- Add Rx NAPI debug counters.
- Make NAPI budget check more generic
- Add a macro bnad_dim_timer_stop for DIM(Dynamic Interrupt Moderation) timer stop
- Handle reduced MSI-X vectors case in bnad_enable_msix
- Replace existing checks with macros and add more checks for illegal skbs in transmit path. Add more tx_skb counters for dropped skbs.
- Check for single frame TSO skbs and send them out as non-TSO.
- Put memory barrier after bna_txq_prod_indx_doorbell()

---
 drivers/net/ethernet/brocade/bna/bnad.c |  207 +++++++++++++++++--------------
 drivers/net/ethernet/brocade/bna/bnad.h |   33 +++++-
 2 files changed, 148 insertions(+), 92 deletions(-)
drivers/net/ethernet/brocade/bna/bnad.c +0 -0
index 64e2106..0faa8a1 100644

drivers/net/ethernet/brocade/bna/bnad.c bnad_poll_cq(struct bnad *bnad, struct bna_ccb *ccb, int budget) · line 538

Quoted 8 lines
drivers/net/ethernet/brocade/bna/bnad.c +1 -1
@@ -532,7 +532,7 @@ bnad_poll_cq(struct bnad *bnad, struct bna_ccb *ccb, int budget)
 		      (flags & BNA_CQ_EF_L4_CKSUM_OK)))
 			skb->ip_summed = CHECKSUM_UNNECESSARY;
 		else
-			skb_checksum_none_assert(skb);
+			skb->ip_summed = CHECKSUM_NONE;
 
 		rcb->rxq->rx_packets++;
 		rcb->rxq->rx_bytes += skb->len;

[...]

This is reverting part of:

commit bc8acf2c8c3e43fcc192762a9f964b3e9a17748b

Author: Eric Dumazet <[email protected]>
Date:   Thu Sep 2 13:07:41 2010 -0700
    drivers/net: avoid some skb->ip_summed initializations

and I don't see any justification for that.

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#15 lore raw

RE: [PATCH 06/14] bna: TX Path and RX Path Changes

Quoted 47 lines

From: Ben Hutchings [mailto:[email protected]]
Sent: Tuesday, August 16, 2011 2:46 PM

Quoted 2 lines · Rasesh Mody

Change details:
- Disable and enable interrupts from the same polling context to

prevent

Quoted 4 lines

reordering in Rx path.
- Add Rx NAPI debug counters.
- Make NAPI budget check more generic
- Add a macro bnad_dim_timer_stop for DIM(Dynamic Interrupt

Moderation)

Quoted 3 lines

timer stop
- Handle reduced MSI-X vectors case in bnad_enable_msix
- Replace existing checks with macros and add more checks for illegal

skbs

Quoted 8 lines

in transmit path. Add more tx_skb counters for dropped skbs.
- Check for single frame TSO skbs and send them out as non-TSO.
- Put memory barrier after bna_txq_prod_indx_doorbell()

---
 drivers/net/ethernet/brocade/bna/bnad.c |  207 +++++++++++++++++-----

---------

Review

Quoted 4 lines
 drivers/net/ethernet/brocade/bna/bnad.h |   33 +++++-
 2 files changed, 148 insertions(+), 92 deletions(-)
(quoted diff) +0 -0

b/drivers/net/ethernet/brocade/bna/bnad.c

drivers/net/ethernet/brocade/bna/bnad.c bnad_poll_cq(struct bnad *bnad, struct bna_ccb

Quoted 4 lines

index 64e2106..0faa8a1 100644

drivers/net/ethernet/brocade/bna/bnad.c +0 -0
@@ -532,7 +532,7 @@ bnad_poll_cq(struct bnad *bnad, struct bna_ccb

*ccb, int budget)

drivers/net/ethernet/brocade/bna/bnad.c bnad_poll_cq(struct bnad *bnad, struct bna_ccb *ccb, int budget) · line 538

Quoted 8 lines
drivers/net/ethernet/brocade/bna/bnad.c +1 -1
 		      (flags & BNA_CQ_EF_L4_CKSUM_OK)))
 			skb->ip_summed = CHECKSUM_UNNECESSARY;
 		else
-			skb_checksum_none_assert(skb);
+			skb->ip_summed = CHECKSUM_NONE;
 
 		rcb->rxq->rx_packets++;
 		rcb->rxq->rx_bytes += skb->len;

[...]

This is reverting part of:

Quoted 7 lines

commit bc8acf2c8c3e43fcc192762a9f964b3e9a17748b

Author: Eric Dumazet <[email protected]>
Date:   Thu Sep 2 13:07:41 2010 -0700
   drivers/net: avoid some skb->ip_summed initializations

and I don't see any justification for that.

It is an erroneous change, this change will be dropped when resubmitting this patch set.
Thanks,
Rasesh

#16 lore raw

PATCH 7/14 bna: Formatting and Code Cleanup

In reply to Rasesh Mody

Change details:
- Print log messages when running with reduced number of MSI-X vectors and when defaulting to INTx mode.
- Remove BUG_ONs and header file inclusion that are not needed
- Comments addition/cleanup
- Unused code cleanup
- Add New Line to Print msg in bfa_sm_fault
- Formatting fix

---
 drivers/net/ethernet/brocade/bna/bfa_cee.c         |    2 -
 .../net/ethernet/brocade/bna/bfa_defs_mfg_comm.h   |    1 -
 drivers/net/ethernet/brocade/bna/bfi.h             |   46 --------------------
 drivers/net/ethernet/brocade/bna/bna.h             |   18 +++-----
 drivers/net/ethernet/brocade/bna/bna_types.h       |    1 -
 drivers/net/ethernet/brocade/bna/bnad.c            |   46 ++++++--------------
 drivers/net/ethernet/brocade/bna/bnad.h            |   13 +++---
 drivers/net/ethernet/brocade/bna/cna.h             |   11 ++---
 8 files changed, 31 insertions(+), 107 deletions(-)
drivers/net/ethernet/brocade/bna/bfa_cee.c +0 -2
index b45b8eb..8e62718 100644
@@ -16,8 +16,6 @@
  * www.brocade.com
  */
 
-#include "bfa_defs_cna.h"
-#include "cna.h"
 #include "bfa_cee.h"
 #include "bfi_cna.h"
 #include "bfa_ioc.h"
drivers/net/ethernet/brocade/bna/bfa_defs_mfg_comm.h +0 -1
index 7ddd16f..7e5df90 100644
@@ -18,7 +18,6 @@
 #ifndef __BFA_DEFS_MFG_COMM_H__
 #define __BFA_DEFS_MFG_COMM_H__
 
-#include "cna.h"
 #include "bfa_defs.h"
 
 /**
drivers/net/ethernet/brocade/bna/bfi.h +0 -46

64 lines not on this page · raw message

drivers/net/ethernet/brocade/bna/bna.h +7 -11
index e4f914c..c0e5ba8 100644
@@ -10,12 +10,17 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
  */
+/*
+ * Copyright (c) 2005-2011 Brocade Communications Systems, Inc.
+ * All rights reserved
+ * www.brocade.com
+ */
 #ifndef __BNA_H__
 #define __BNA_H__
 
-#include "bfa_cs.h"
+#include "bfa_defs.h"
 #include "bfa_ioc.h"
-#include "cna.h"
+#include "bfi_enet.h"
 #include "bna_types.h"
 
 extern const u32 bna_napi_dim_vector[][BNA_BIAS_T_MAX];
@@ -403,12 +408,8 @@ void bna_mod_init(struct bna *bna, struct bna_res_info *res_info);
 void bna_uninit(struct bna *bna);
 int bna_num_txq_set(struct bna *bna, int num_txq);
 int bna_num_rxp_set(struct bna *bna, int num_rxp);
-void bna_stats_get(struct bna *bna);
-void bna_get_perm_mac(struct bna *bna, u8 *mac);
 void bna_hw_stats_get(struct bna *bna);
 
-/* APIs for Rx */
-
 /* APIs for RxF */
 struct bna_mac *bna_ucam_mod_mac_get(struct bna_ucam_mod *ucam_mod);
 void bna_ucam_mod_mac_put(struct bna_ucam_mod *ucam_mod,
@@ -529,11 +530,6 @@ bna_rx_mode_set(struct bna_rx *rx, enum bna_rxmode rxmode,
 void bna_rx_vlan_add(struct bna_rx *rx, int vlan_id);
 void bna_rx_vlan_del(struct bna_rx *rx, int vlan_id);
 void bna_rx_vlanfilter_enable(struct bna_rx *rx);
-void bna_rx_hds_enable(struct bna_rx *rx, struct bna_hds_config *hds_config,
-		       void (*cbfn)(struct bnad *, struct bna_rx *));
-void bna_rx_hds_disable(struct bna_rx *rx,
-			void (*cbfn)(struct bnad *, struct bna_rx *));
-
 /**
  * ENET
  */
drivers/net/ethernet/brocade/bna/bna_types.h +0 -1
index 8a6da0c..59417b1 100644
@@ -21,7 +21,6 @@
 #include "cna.h"
 #include "bna_hw_defs.h"
 #include "bfa_cee.h"
-#include "bfi_enet.h"
 #include "bfa_msgq.h"
 
 /**
drivers/net/ethernet/brocade/bna/bnad.c +13 -33

120 lines not on this page · raw message

drivers/net/ethernet/brocade/bna/bnad.h +7 -6
index f402149..516fbdd 100644
@@ -64,8 +64,6 @@ struct bnad_rx_ctrl {
 
 #define BNAD_RXMODE_PROMISC_DEFAULT	BNA_RXMODE_PROMISC
 
-#define BNAD_GET_TX_ID(_skb)	(0)
-
 /*
  * GLOBAL #defines (CONSTANTS)
  */
@@ -154,7 +152,6 @@ struct bnad_drv_stats {
 	u64		tcpcsum_offload;
 	u64		udpcsum_offload;
 	u64		csum_help;
-	u64		csum_help_err;
 	u64		tx_skb_too_short;
 	u64		tx_skb_stopping;
 	u64		tx_skb_max_vectors;
@@ -171,13 +168,10 @@ struct bnad_drv_stats {
 	u64		tx_skb_len_mismatch;
 
 	u64		hw_stats_updates;
-	u64		netif_rx_schedule;
-	u64		netif_rx_complete;
 	u64		netif_rx_dropped;
 
 	u64		link_toggle;
 	u64		cee_toggle;
-	u64		cee_up;
 
 	u64		rxp_info_alloc_failed;
 	u64		mbox_intr_disabled;
@@ -386,6 +380,13 @@ extern void bnad_netdev_hwstats_fill(struct bnad *bnad,
 #define bnad_dim_timer_running(_bnad)				\
 	(((_bnad)->cfg_flags & BNAD_CF_DIM_ENABLED) &&		\
 	(test_bit(BNAD_RF_DIM_TIMER_RUNNING, &((_bnad)->run_flags))))
+
+/*
+ * Stops the DIM timer
+ * Called with bnad->bna_lock held
+ * Implemented as macro, since we want to use
+ * the correct flags(on stack) while unlocking.
+ */
 #define bnad_dim_timer_stop(_bnad, _flags)		\
 do {							\
 	int to_del = 0;					\
drivers/net/ethernet/brocade/bna/cna.h +4 -7
index 50fce15..cb48742 100644
@@ -21,21 +21,18 @@
 
 #include <linux/kernel.h>
 #include <linux/types.h>
+#include <linux/mutex.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/bitops.h>
 #include <linux/timer.h>
 #include <linux/interrupt.h>
+#include <linux/if_vlan.h>
 #include <linux/if_ether.h>
-#include <asm/page.h>
-#include <asm/io.h>
-#include <asm/string.h>
-
-#include <linux/list.h>
 
 #define bfa_sm_fault(__event)    do {                            \
-	pr_err("SM Assertion failure: %s: %d: event = %d", __FILE__, __LINE__, \
-		__event); \
+	pr_err("SM Assertion failure: %s: %d: event = %d\n",	\
+		 __FILE__, __LINE__, __event);			\
 } while (0)
 
 extern char bfa_version[];
Signature · 1 line
1.7.1
#17 lore raw

PATCH 8/14 bna: Initialization and Locking Fix

In reply to Rasesh Mody

Change details:
- Initialize rx_id to 0 for bnad_cleanup_rx
- Return -ENOMEM in case if bna_rx_create fails
- Count the Rx buffer allocation failures in bnad_alloc_n_post_rxbufs()
- Remove unnecessary initialization of using_dac to false in bnad_pci_probe
- Release lock if error while doing bna_num_txq_set in bnad_pci_probe
- Release all the locks while doing free_netdev

---
 drivers/net/ethernet/brocade/bna/bna_hw_defs.h |    1 +
 drivers/net/ethernet/brocade/bna/bnad.c        |   15 ++++++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)
drivers/net/ethernet/brocade/bna/bna_hw_defs.h +1 -0
index 07bb792..7ecdca5 100644
@@ -99,6 +99,7 @@
 	(_bna)->bits.error_status_bits = (__HFN_INT_ERR_MASK);		\
 	(_bna)->bits.error_mask_bits = (__HFN_INT_ERR_MASK);		\
 	(_bna)->bits.halt_status_bits = __HFN_INT_LL_HALT;		\
+	(_bna)->bits.halt_mask_bits = __HFN_INT_LL_HALT;		\
 }
 
 #define ct2_reg_addr_init(_bna, _pcidev)				\
drivers/net/ethernet/brocade/bna/bnad.c +12 -3
index 869d172..11c058e 100644
@@ -409,6 +409,7 @@ bnad_alloc_n_post_rxbufs(struct bnad *bnad, struct bna_rcb *rcb)
 						rcb->rxq->buffer_size);
 		if (unlikely(!skb)) {
 			BNAD_UPDATE_CTR(bnad, rxbuf_alloc_failed);
+			rcb->rxq->rxbuf_alloc_failed++;
 			goto finishing;
 		}
 		unmap_array[unmap_prod].skb = skb;
@@ -1900,6 +1901,7 @@ bnad_cleanup_rx(struct bnad *bnad, u32 rx_id)
 	spin_unlock_irqrestore(&bnad->bna_lock, flags);
 
 	rx_info->rx = NULL;
+	rx_info->rx_id = 0;
 
 	bnad_rx_res_free(bnad, res_info);
 }
@@ -1955,8 +1957,10 @@ bnad_setup_rx(struct bnad *bnad, u32 rx_id)
 	rx = bna_rx_create(&bnad->bna, bnad, rx_config, &rx_cbfn, res_info,
 			rx_info);
 	spin_unlock_irqrestore(&bnad->bna_lock, flags);
-	if (!rx)
+	if (!rx) {
+		err = -ENOMEM;
 		goto err_return;
+	}
 	rx_info->rx = rx;
 
 	/*
@@ -3234,7 +3238,7 @@ static int __devinit
 bnad_pci_probe(struct pci_dev *pdev,
 		const struct pci_device_id *pcidev_id)
 {
-	bool	using_dac = false;
+	bool	using_dac;
 	int	err;
 	struct bnad *bnad;
 	struct bna *bna;
@@ -3357,6 +3361,11 @@ bnad_pci_probe(struct pci_dev *pdev,
 			bna_num_rxp_set(bna, BNAD_NUM_RXP + 1))
 			err = -EIO;
 	}
+	spin_unlock_irqrestore(&bnad->bna_lock, flags);
+	if (err)
+		goto disable_ioceth;
+
+	spin_lock_irqsave(&bnad->bna_lock, flags);
 	bna_mod_res_req(&bnad->bna, &bnad->mod_res_info[0]);
 	spin_unlock_irqrestore(&bnad->bna_lock, flags);
 
@@ -3410,9 +3419,9 @@ drv_uninit:
 	bnad_uninit(bnad);
 pci_uninit:
 	bnad_pci_uninit(pdev);
+free_netdev:
 	mutex_unlock(&bnad->conf_mutex);
 	bnad_lock_uninit(bnad);
-free_netdev:
 	free_netdev(netdev);
 	return err;
 }
Signature · 1 line
1.7.1
#18 lore raw

PATCH 9/14 bna: Ethtool Enhancements and Fix

In reply to Rasesh Mody

Change details:
- Set coalescing time out for multiple tx objects.
- Use bnad_dim_timer_stop macro in bnad_set_coalesce.
- Add tx_skb counters and NAPI debug counters to ethtool stats.
- Add rlb stats strings to bnad_net_stats_strings{} array. rlb_stats field was added to struct bfi_enet_stats {} but the corresponding name structure array for ethtool was not initialized with right strings, even though the actual name structure array got expanded. This caused a NULL pointer violation and a crash when doing ehtool -S <if_name>.
- While setting the ring parameter restore the rx, vlan configuration and set rx mode
- Indentation fix

---
 drivers/net/ethernet/brocade/bna/bnad.c         |   21 +++---
 drivers/net/ethernet/brocade/bna/bnad.h         |   10 ++-
 drivers/net/ethernet/brocade/bna/bnad_ethtool.c |   88 +++++++++++++++++++----
 3 files changed, 92 insertions(+), 27 deletions(-)
drivers/net/ethernet/brocade/bna/bnad.c +12 -9
index 11c058e..76bfa19 100644
@@ -2008,12 +2008,15 @@ void
 bnad_tx_coalescing_timeo_set(struct bnad *bnad)
 {
 	struct bnad_tx_info *tx_info;
+	int i;
 
-	tx_info = &bnad->tx_info[0];
-	if (!tx_info->tx)
-		return;
-
-	bna_tx_coalescing_timeo_set(tx_info->tx, bnad->tx_coalescing_timeo);
+	for (i = 0; i < bnad->num_tx; i++) {
+		tx_info = &bnad->tx_info[i];
+		if (!tx_info->tx)
+			continue;
+		bna_tx_coalescing_timeo_set(tx_info->tx,
+				bnad->tx_coalescing_timeo);
+	}
 }
 
 /* Called with conf_lock & bnad->bna_lock held */
@@ -2035,7 +2038,7 @@ bnad_rx_coalescing_timeo_set(struct bnad *bnad)
 /*
  * Called with bnad->bna_lock held
  */
-static int
+int
 bnad_mac_addr_set_locked(struct bnad *bnad, u8 *mac_addr)
 {
 	int ret;
@@ -2055,7 +2058,7 @@ bnad_mac_addr_set_locked(struct bnad *bnad, u8 *mac_addr)
 }
 
 /* Should be called with conf_lock held */
-static int
+int
 bnad_enable_default_bcast(struct bnad *bnad)
 {
 	struct bnad_rx_info *rx_info = &bnad->rx_info[0];
@@ -2081,7 +2084,7 @@ bnad_enable_default_bcast(struct bnad *bnad)
 }
 
 /* Called with mutex_lock(&bnad->conf_mutex) held */
-static void
+void
 bnad_restore_vlans(struct bnad *bnad, u32 rx_id)
 {
 	u16 vid;
@@ -2852,7 +2855,7 @@ bnad_tx_select_queue(struct net_device *netdev, struct sk_buff *skb)
 	return (u16)prio;
 }
 
-static void
+void
 bnad_set_rx_mode(struct net_device *netdev)
 {
 	struct bnad *bnad = netdev_priv(netdev);
drivers/net/ethernet/brocade/bna/bnad.h +6 -4
index 516fbdd..3132c50 100644
@@ -339,6 +339,12 @@ extern u32		bnad_rxqs_per_cq;
  */
 extern u32 *cna_get_firmware_buf(struct pci_dev *pdev);
 /* Netdev entry point prototypes */
+extern void bnad_set_rx_mode(struct net_device *netdev);
+extern struct net_device_stats *bnad_get_netdev_stats(
+				struct net_device *netdev);
+extern int bnad_mac_addr_set_locked(struct bnad *bnad, u8 *mac_addr);
+extern int bnad_enable_default_bcast(struct bnad *bnad);
+extern void bnad_restore_vlans(struct bnad *bnad, u32 rx_id);
 extern void bnad_set_ethtool_ops(struct net_device *netdev);
 
 /* Configuration & setup */
@@ -377,10 +383,6 @@ extern void bnad_netdev_hwstats_fill(struct bnad *bnad,
 	}							\
 }
 
-#define bnad_dim_timer_running(_bnad)				\
-	(((_bnad)->cfg_flags & BNAD_CF_DIM_ENABLED) &&		\
-	(test_bit(BNAD_RF_DIM_TIMER_RUNNING, &((_bnad)->run_flags))))
-
 /*
  * Stops the DIM timer
  * Called with bnad->bna_lock held
drivers/net/ethernet/brocade/bna/bnad_ethtool.c +74 -14

156 lines not on this page · raw message

Signature · 1 line
1.7.1
#19 lore raw

Re: [PATCH 09/14] bna: Ethtool Enhancements and Fix

Quoted 34 lines · Rasesh Mody

Change details:
- Set coalescing time out for multiple tx objects.
- Use bnad_dim_timer_stop macro in bnad_set_coalesce.
- Add tx_skb counters and NAPI debug counters to ethtool stats.
- Add rlb stats strings to bnad_net_stats_strings{} array. rlb_stats field was added to struct bfi_enet_stats {} but the corresponding name structure array for ethtool was not initialized with right strings, even though the actual name structure array got expanded. This caused a NULL pointer violation and a crash when doing ehtool -S <if_name>.
- While setting the ring parameter restore the rx, vlan configuration and set rx mode
- Indentation fix

---
 drivers/net/ethernet/brocade/bna/bnad.c         |   21 +++---
 drivers/net/ethernet/brocade/bna/bnad.h         |   10 ++-
 drivers/net/ethernet/brocade/bna/bnad_ethtool.c |   88 +++++++++++++++++++----
 3 files changed, 92 insertions(+), 27 deletions(-)
drivers/net/ethernet/brocade/bna/bnad.c +1 -3
index 11c058e..76bfa19 100644
@@ -2008,12 +2008,15 @@ void
 bnad_tx_coalescing_timeo_set(struct bnad *bnad)
 {
 	struct bnad_tx_info *tx_info;
+	int i;
 
-	tx_info = &bnad->tx_info[0];
-	if (!tx_info->tx)
-		return;

drivers/net/ethernet/brocade/bna/bnad.c void · line 2020

Quoted 10 lines
drivers/net/ethernet/brocade/bna/bnad.c +7 -2
-
-	bna_tx_coalescing_timeo_set(tx_info->tx, bnad->tx_coalescing_timeo);
+	for (i = 0; i < bnad->num_tx; i++) {
+		tx_info = &bnad->tx_info[i];
+		if (!tx_info->tx)
+			continue;
+		bna_tx_coalescing_timeo_set(tx_info->tx,
+				bnad->tx_coalescing_timeo);
+	}
 }

[...]

Doesn't this need to be done at the same time as patch 04/14 "bna: Add Multiple Tx Queue Support"?

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#20 lore raw

RE: [PATCH 09/14] bna: Ethtool Enhancements and Fix

Quoted 58 lines

From: Ben Hutchings [mailto:[email protected]]
Sent: Tuesday, August 16, 2011 2:43 PM

Quoted 5 lines · Rasesh Mody

Change details:
- Set coalescing time out for multiple tx objects.
- Use bnad_dim_timer_stop macro in bnad_set_coalesce.
- Add tx_skb counters and NAPI debug counters to ethtool stats.
- Add rlb stats strings to bnad_net_stats_strings{} array. rlb_stats

field

Quoted 1 line

was added to struct bfi_enet_stats {} but the corresponding name

structure

Quoted 1 line

array for ethtool was not initialized with right strings, even

though the

Quoted 1 line

actual name structure array got expanded. This caused a NULL

pointer

Quoted 2 lines

violation and a crash when doing ehtool -S <if_name>.
- While setting the ring parameter restore the rx, vlan configuration

and

Quoted 9 lines

set rx mode
- Indentation fix

---
 drivers/net/ethernet/brocade/bna/bnad.c         |   21 +++---
 drivers/net/ethernet/brocade/bna/bnad.h         |   10 ++-
 drivers/net/ethernet/brocade/bna/bnad_ethtool.c |   88

+++++++++++++++++++----

Review

Quoted 3 lines
 3 files changed, 92 insertions(+), 27 deletions(-)
(quoted diff) +0 -0

b/drivers/net/ethernet/brocade/bna/bnad.c

Quoted 23 lines

index 11c058e..76bfa19 100644

drivers/net/ethernet/brocade/bna/bnad.c +8 -5
@@ -2008,12 +2008,15 @@ void
 bnad_tx_coalescing_timeo_set(struct bnad *bnad)
 {
 	struct bnad_tx_info *tx_info;
+	int i;
 
-	tx_info = &bnad->tx_info[0];
-	if (!tx_info->tx)
-		return;
-
-	bna_tx_coalescing_timeo_set(tx_info->tx, bnad-
 tx_coalescing_timeo);
+	for (i = 0; i < bnad->num_tx; i++) {
+		tx_info = &bnad->tx_info[i];
+		if (!tx_info->tx)
+			continue;
+		bna_tx_coalescing_timeo_set(tx_info->tx,
+				bnad->tx_coalescing_timeo);
+	}
 }

[...]

Quoted 2 lines

Doesn't this need to be done at the same time as patch 04/14 "bna: Add Multiple Tx Queue Support"?

Ben,
Thanks for the feedback!

Yes, this is Multiple TXQ related change and will move it to 04/14. Since ethtool is using it, we thought it would make more sense to do this change with other ethtool changes.

Rasesh

#21 lore raw

PATCH 10/14 bna: Async Mode Tx Rx Init Fix

In reply to Rasesh Mody

Change details:
- Async mode of Tx/Rx queue initialization in BNAD from a task queue context runs into non-unique taskq allocation issues. Get rid of Tx/Rx initialization from task q context
- In the attach function, wait for IOC enable, then do Tx/Rx queue initialization. Default BNA attributes are used when IOC enable from attach fails and values are set to:
1 TxQ, 1 RxQ, 1 Unicast MAC, 1 RIT entry

---
 drivers/net/ethernet/brocade/bna/bna_enet.c    |   29 ++++++++++++++++++-----
 drivers/net/ethernet/brocade/bna/bna_hw_defs.h |    4 +++
 drivers/net/ethernet/brocade/bna/bna_types.h   |    1 +
 3 files changed, 27 insertions(+), 7 deletions(-)
drivers/net/ethernet/brocade/bna/bna_enet.c +22 -7
index 68a275d..26f5c5a 100644
@@ -167,13 +167,14 @@ bna_bfi_attr_get_rsp(struct bna_ioceth *ioceth,
 	 * Store only if not set earlier, since BNAD can override the HW
 	 * attributes
 	 */
-	if (!ioceth->attr.num_txq)
+	if (!ioceth->attr.fw_query_complete) {
 		ioceth->attr.num_txq = ntohl(rsp->max_cfg);
-	if (!ioceth->attr.num_rxp)
 		ioceth->attr.num_rxp = ntohl(rsp->max_cfg);
-	ioceth->attr.num_ucmac = ntohl(rsp->max_ucmac);
-	ioceth->attr.num_mcmac = BFI_ENET_MAX_MCAM;
-	ioceth->attr.max_rit_size = ntohl(rsp->rit_size);
+		ioceth->attr.num_ucmac = ntohl(rsp->max_ucmac);
+		ioceth->attr.num_mcmac = BFI_ENET_MAX_MCAM;
+		ioceth->attr.max_rit_size = ntohl(rsp->rit_size);
+		ioceth->attr.fw_query_complete = true;
+	}
 
 	bfa_fsm_send_event(ioceth, IOCETH_E_ENET_ATTR_RESP);
 }
@@ -1693,6 +1694,16 @@ static struct bfa_ioc_cbfn bna_ioceth_cbfn = {
 	bna_cb_ioceth_reset
 };
 
+static void bna_attr_init(struct bna_ioceth *ioceth)
+{
+	ioceth->attr.num_txq = BFI_ENET_DEF_TXQ;
+	ioceth->attr.num_rxp = BFI_ENET_DEF_RXP;
+	ioceth->attr.num_ucmac = BFI_ENET_DEF_UCAM;
+	ioceth->attr.num_mcmac = BFI_ENET_MAX_MCAM;
+	ioceth->attr.max_rit_size = BFI_ENET_DEF_RITSZ;
+	ioceth->attr.fw_query_complete = false;
+}
+
 static void
 bna_ioceth_init(struct bna_ioceth *ioceth, struct bna *bna,
 		struct bna_res_info *res_info)
@@ -1738,6 +1749,8 @@ bna_ioceth_init(struct bna_ioceth *ioceth, struct bna *bna,
 	ioceth->stop_cbfn = NULL;
 	ioceth->stop_cbarg = NULL;
 
+	bna_attr_init(ioceth);
+
 	bfa_fsm_set_state(ioceth, bna_ioceth_sm_stopped);
 }
 
@@ -2036,7 +2049,8 @@ bna_uninit(struct bna *bna)
 int
 bna_num_txq_set(struct bna *bna, int num_txq)
 {
-	if (num_txq > 0 && (num_txq <= bna->ioceth.attr.num_txq)) {
+	if (bna->ioceth.attr.fw_query_complete &&
+		(num_txq <= bna->ioceth.attr.num_txq)) {
 		bna->ioceth.attr.num_txq = num_txq;
 		return BNA_CB_SUCCESS;
 	}
@@ -2047,7 +2061,8 @@ bna_num_txq_set(struct bna *bna, int num_txq)
 int
 bna_num_rxp_set(struct bna *bna, int num_rxp)
 {
-	if (num_rxp > 0 && (num_rxp <= bna->ioceth.attr.num_rxp)) {
+	if (bna->ioceth.attr.fw_query_complete &&
+		(num_rxp <= bna->ioceth.attr.num_rxp)) {
 		bna->ioceth.attr.num_rxp = num_rxp;
 		return BNA_CB_SUCCESS;
 	}
drivers/net/ethernet/brocade/bna/bna_hw_defs.h +4 -0
index 7ecdca5..dde8a46 100644
@@ -30,6 +30,10 @@
  * SW imposed limits
  *
  */
+#define BFI_ENET_DEF_TXQ		1
+#define BFI_ENET_DEF_RXP		1
+#define BFI_ENET_DEF_UCAM		1
+#define BFI_ENET_DEF_RITSZ		1
 
 #define BFI_ENET_MAX_MCAM		256
 
drivers/net/ethernet/brocade/bna/bna_types.h +1 -0
index 59417b1..242d799 100644
@@ -323,6 +323,7 @@ struct bna_qpt {
 };
 
 struct bna_attr {
+	bool			fw_query_complete;
 	int			num_txq;
 	int			num_rxp;
 	int			num_ucmac;
Signature · 1 line
1.7.1
#22 lore raw

PATCH 11/14 bna: MBOX IRQ Flag Check after Locking

In reply to Rasesh Mody

Change details:
- Check the BNAD_RF_MBOX_IRQ_DISABLED flag after acquiring the bna_lock.

---
 drivers/net/ethernet/brocade/bna/bnad.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)
drivers/net/ethernet/brocade/bna/bnad.c +11 -7
index 76bfa19..5d431de 100644
@@ -602,10 +602,11 @@ bnad_msix_mbox_handler(int irq, void *data)
 	unsigned long flags;
 	struct bnad *bnad = (struct bnad *)data;
 
-	if (unlikely(test_bit(BNAD_RF_MBOX_IRQ_DISABLED, &bnad->run_flags)))
-		return IRQ_HANDLED;
-
 	spin_lock_irqsave(&bnad->bna_lock, flags);
+	if (unlikely(test_bit(BNAD_RF_MBOX_IRQ_DISABLED, &bnad->run_flags))) {
+		spin_unlock_irqrestore(&bnad->bna_lock, flags);
+		return IRQ_HANDLED;
+	}
 
 	bna_intr_status_get(&bnad->bna, intr_status);
 
@@ -628,15 +629,18 @@ bnad_isr(int irq, void *data)
 	struct bnad_rx_ctrl *rx_ctrl;
 	struct bna_tcb *tcb = NULL;
 
-	if (unlikely(test_bit(BNAD_RF_MBOX_IRQ_DISABLED, &bnad->run_flags)))
+	spin_lock_irqsave(&bnad->bna_lock, flags);
+	if (unlikely(test_bit(BNAD_RF_MBOX_IRQ_DISABLED, &bnad->run_flags))) {
+		spin_unlock_irqrestore(&bnad->bna_lock, flags);
 		return IRQ_NONE;
+	}
 
 	bna_intr_status_get(&bnad->bna, intr_status);
 
-	if (unlikely(!intr_status))
+	if (unlikely(!intr_status)) {
+		spin_unlock_irqrestore(&bnad->bna_lock, flags);
 		return IRQ_NONE;
-
-	spin_lock_irqsave(&bnad->bna_lock, flags);
+	}
 
 	if (BNA_IS_MBOX_ERR_INTR(&bnad->bna, intr_status))
 		bna_mbox_handler(&bnad->bna, intr_status);
Signature · 1 line
1.7.1
#23 lore raw

PATCH 12/14 bna: Queue Depth and SKB Unmap Array Fix

In reply to Rasesh Mody

Change details:
- Replaced global variable bnad_rxqs_per_cq with define BNAD_RXQS_PER_CQ
- sk_buff unmap_array grows greater than 65536 (x2) with Tx ring of 65536. The index used for accessing it is incorrectly declared as u16. It quickly wraps around and accesses null sk_buff ptr. So using u32 to handle unmap_array.
- Reducing TXQ depth and safe(max) acking of Tx events to 32768 (same as Rx)

---
 drivers/net/ethernet/brocade/bna/bnad.c         |    6 ++----
 drivers/net/ethernet/brocade/bna/bnad.h         |    6 +++++-
 drivers/net/ethernet/brocade/bna/bnad_ethtool.c |    8 ++++----
 3 files changed, 11 insertions(+), 9 deletions(-)
drivers/net/ethernet/brocade/bna/bnad.c +2 -4
index 5d431de..4e80df3 100644
@@ -46,8 +46,6 @@ MODULE_PARM_DESC(bnad_ioc_auto_recover, "Enable / Disable auto recovery");
 /*
  * Global variables
  */
-u32 bnad_rxqs_per_cq = 2;
-
 static const u8 bnad_bcast_addr[] =  {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
 
 /*
@@ -194,8 +192,8 @@ static u32
 bnad_free_txbufs(struct bnad *bnad,
 		 struct bna_tcb *tcb)
 {
-	u32		sent_packets = 0, sent_bytes = 0;
-	u16		wis, unmap_cons, updated_hw_cons;
+	u32		unmap_cons, sent_packets = 0, sent_bytes = 0;
+	u16		wis, updated_hw_cons;
 	struct bnad_unmap_q *unmap_q = tcb->unmap_q;
 	struct bnad_skb_unmap *unmap_array;
 	struct sk_buff		*skb;
drivers/net/ethernet/brocade/bna/bnad.h +5 -1
index 3132c50..df57e85 100644
@@ -85,6 +85,11 @@ struct bnad_rx_ctrl {
 #define BNAD_MAX_Q_DEPTH		0x10000
 #define BNAD_MIN_Q_DEPTH		0x200
 
+#define BNAD_RXQS_PER_CQ		2
+#define BNAD_MAX_RXQ_DEPTH		(BNAD_MAX_Q_DEPTH / BNAD_RXQS_PER_CQ)
+/* keeping MAX TX and RX Q depth equal */
+#define BNAD_MAX_TXQ_DEPTH		BNAD_MAX_RXQ_DEPTH
+
 #define BNAD_JUMBO_MTU			9000
 
 #define BNAD_NETIF_WAKE_THRESHOLD	8
@@ -332,7 +337,6 @@ struct bnad {
  * EXTERN VARIABLES
  */
 extern struct firmware *bfi_fw;
-extern u32		bnad_rxqs_per_cq;
 
 /*
  * EXTERN PROTOTYPES
drivers/net/ethernet/brocade/bna/bnad_ethtool.c +4 -4
index 1199f01..e85fb2b 100644
@@ -407,10 +407,10 @@ bnad_get_ringparam(struct net_device *netdev,
 {
 	struct bnad *bnad = netdev_priv(netdev);
 
-	ringparam->rx_max_pending = BNAD_MAX_Q_DEPTH / bnad_rxqs_per_cq;
+	ringparam->rx_max_pending = BNAD_MAX_RXQ_DEPTH;
 	ringparam->rx_mini_max_pending = 0;
 	ringparam->rx_jumbo_max_pending = 0;
-	ringparam->tx_max_pending = BNAD_MAX_Q_DEPTH;
+	ringparam->tx_max_pending = BNAD_MAX_TXQ_DEPTH;
 
 	ringparam->rx_pending = bnad->rxq_depth;
 	ringparam->rx_mini_max_pending = 0;
@@ -434,13 +434,13 @@ bnad_set_ringparam(struct net_device *netdev,
 	}
 
 	if (ringparam->rx_pending < BNAD_MIN_Q_DEPTH ||
-	    ringparam->rx_pending > BNAD_MAX_Q_DEPTH / bnad_rxqs_per_cq ||
+	    ringparam->rx_pending > BNAD_MAX_RXQ_DEPTH ||
 	    !BNA_POWER_OF_2(ringparam->rx_pending)) {
 		mutex_unlock(&bnad->conf_mutex);
 		return -EINVAL;
 	}
 	if (ringparam->tx_pending < BNAD_MIN_Q_DEPTH ||
-	    ringparam->tx_pending > BNAD_MAX_Q_DEPTH ||
+	    ringparam->tx_pending > BNAD_MAX_TXQ_DEPTH ||
 	    !BNA_POWER_OF_2(ringparam->tx_pending)) {
 		mutex_unlock(&bnad->conf_mutex);
 		return -EINVAL;
Signature · 1 line
1.7.1
#24 lore raw

PATCH 13/14 bna: SKB PCI UNMAP Fix

In reply to Rasesh Mody

Change details:
- Found a leak in sk_buff unmapping of PCI dma addresses where boundary conditions are not properly handled in freeing all Tx buffers. Freeing of all Tx buffers is done considering sk_buffs data and fragments can be mapped at the boundary.

---
 drivers/net/ethernet/brocade/bna/bnad.c |   39 ++++++++-----------------------
 1 files changed, 10 insertions(+), 29 deletions(-)
drivers/net/ethernet/brocade/bna/bnad.c +8 -27
index 4e80df3..99a4688 100644
@@ -143,39 +143,20 @@ bnad_free_all_txbufs(struct bnad *bnad,
 	struct bnad_unmap_q *unmap_q = tcb->unmap_q;
 	struct bnad_skb_unmap *unmap_array;
 	struct sk_buff		*skb = NULL;
-	int			i;
+	int			q;
 
 	unmap_array = unmap_q->unmap_array;
 
-	unmap_cons = 0;
-	while (unmap_cons < unmap_q->q_depth) {
-		skb = unmap_array[unmap_cons].skb;
-		if (!skb) {
-			unmap_cons++;
+	for (q = 0; q < unmap_q->q_depth; q++) {
+		skb = unmap_array[q].skb;
+		if (!skb)
 			continue;
-		}
-		unmap_array[unmap_cons].skb = NULL;
-
-		dma_unmap_single(&bnad->pcidev->dev,
-				 dma_unmap_addr(&unmap_array[unmap_cons],
-						dma_addr), skb_headlen(skb),
-						DMA_TO_DEVICE);
 
-		dma_unmap_addr_set(&unmap_array[unmap_cons], dma_addr, 0);
-		if (++unmap_cons >= unmap_q->q_depth)
-			break;
+		unmap_cons = q;
+		BNAD_PCI_UNMAP_SKB(&bnad->pcidev->dev, unmap_array, unmap_cons,
+				   unmap_q->q_depth, skb,
+				   skb_shinfo(skb)->nr_frags);
 
-		for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
-			dma_unmap_page(&bnad->pcidev->dev,
-				       dma_unmap_addr(&unmap_array[unmap_cons],
-						      dma_addr),
-				       skb_shinfo(skb)->frags[i].size,
-				       DMA_TO_DEVICE);
-			dma_unmap_addr_set(&unmap_array[unmap_cons], dma_addr,
-					   0);
-			if (++unmap_cons >= unmap_q->q_depth)
-				break;
-		}
 		dev_kfree_skb_any(skb);
 	}
 }
Signature · 1 line
1.7.1
#25 lore raw

PATCH 14/14 bna: Driver Version changed to 3.0.2.1

In reply to Rasesh Mody
---
 drivers/net/ethernet/brocade/bna/bnad.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/ethernet/brocade/bna/bnad.h +1 -1
index df57e85..6f1e972 100644
@@ -70,7 +70,7 @@ struct bnad_rx_ctrl {
 #define BNAD_NAME			"bna"
 #define BNAD_NAME_LEN			64
 
-#define BNAD_VERSION			"3.0.2.0"
+#define BNAD_VERSION			"3.0.2.1"
 
 #define BNAD_MAILBOX_MSIX_INDEX		0
 #define BNAD_MAILBOX_MSIX_VECTORS	1
Signature · 1 line
1.7.1