Netdev List
 help / color / mirror / Atom feed
* RE: IPV6 ndisc::  Bad NIC causing  IPV6 NDP to stop working
From: Menny_Hamburger @ 2012-07-08  8:46 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev
In-Reply-To: <1340270190.4604.4640.camel@edumazet-glaptop>

After some debugging we found that our network driver sometimes fails to release the skb after calls to tx_start_xmit, which caused the ndisc socket send buffer to become full.
(sock_alloc_send_skb would fail on (atomic_read(&sk->sk_wmwm_alloc) < sk->sk_sndbuf) ). 
We also witnessed allocation failures in cases where we have a number of different NICS (1GB, 10GB, ...) - the slowest NIC becomes a bottleneck.
Using alloc_skb instead of sock_alloc_skb fixes this problem; my only concern is that in the extreme cases of a stray driver or some memory corruption, the absence of an upper limit to the skb 
allocation may consume the skbuff cache and cause all networking to behave badly.

Thanks,
Menny

net/ipv6/ndisc.c |   24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)


diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 69a6330..f149d85 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -429,7 +429,6 @@ struct sk_buff *ndisc_build_skb(struct net_device *dev,
 	int hlen = LL_RESERVED_SPACE(dev);
 	int tlen = dev->needed_tailroom;
 	int len;
-	int err;
 	u8 *opt;
 
 	if (!dev->addr_len)
@@ -439,15 +438,10 @@ struct sk_buff *ndisc_build_skb(struct net_device *dev,
 	if (llinfo)
 		len += ndisc_opt_addr_space(dev);
 
-	skb = sock_alloc_send_skb(sk,
-				  (MAX_HEADER + sizeof(struct ipv6hdr) +
-				   len + hlen + tlen),
-				  1, &err);
-	if (!skb) {
-		ND_PRINTK(0, err, "ND: %s failed to allocate an skb, err=%d\n",
-			  __func__, err);
+	skb = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) + len + hlen + tlen,
+			GFP_ATOMIC);
+	if (!skb)
 		return NULL;
-	}
 
 	skb_reserve(skb, hlen);
 	ip6_nd_hdr(sk, skb, dev, saddr, daddr, IPPROTO_ICMPV6, len);
@@ -1550,16 +1544,10 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
 
 	hlen = LL_RESERVED_SPACE(dev);
 	tlen = dev->needed_tailroom;
-	buff = sock_alloc_send_skb(sk,
-				   (MAX_HEADER + sizeof(struct ipv6hdr) +
-				    len + hlen + tlen),
-				   1, &err);
-	if (buff == NULL) {
-		ND_PRINTK(0, err,
-			  "Redirect: %s failed to allocate an skb, err=%d\n",
-			  __func__, err);
+	buff = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) + len + hlen + tlen,
+			 GFP_ATOMIC);
+	if (!buff)
 		goto release;
-	}
 
 	skb_reserve(buff, hlen);
 	ip6_nd_hdr(sk, buff, dev, &saddr_buf, &ipv6_hdr(skb)->saddr,



^ permalink raw reply related

* Re: [PATCH] gianfar: fix potential sk_wmem_alloc imbalance
From: Eric Dumazet @ 2012-07-08  9:09 UTC (permalink / raw)
  To: Paul Gortmaker
  Cc: David Miller, netdev, Manfred Rudigier, Claudiu Manoil, Jiajun Wu,
	Andy Fleming
In-Reply-To: <20120706180947.GI1817@windriver.com>

On Fri, 2012-07-06 at 14:09 -0400, Paul Gortmaker wrote:

> Aside from the one line change at driver init, is there more to it than
> that?  More specifically, it currently does:
> 
> fcb_length = GMAC_FCB_LEN;
> 
> if (...timestamps...)
> 	fcb_length = GMAC_FCB_LEN + GMAC_TXPAL_LEN;
> 
> if (... && (skb_headroom(skb) < fcb_length))
> 	...
> 	skb_new = skb_realloc_headroom(skb, fcb_length);
> 
> and I don't know the code well enough to know if setting the
> needed_headroom value _guarantees_ the above fcb_length comparison
> will always be false, and hence can be deleted.  It kind of looks
> like it via LL_RESERVED_SPACE, but I'm not 100% sure...

This is not a guarantee but should take care of most cases.

So we should keep the test anyway.

And init needed_headroom to the largest room. Existing tests seems to
ignore vlan case and timestamping.

diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index af16f9f..b4517b7 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -1084,9 +1084,7 @@ static int gfar_probe(struct platform_device *ofdev)
 	else
 		priv->padding = 0;
 
-	if (dev->features & NETIF_F_IP_CSUM ||
-	    priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER)
-		dev->needed_headroom = GMAC_FCB_LEN;
+	dev->needed_headroom = GMAC_FCB_LEN + GMAC_TXPAL_LEN;
 
 	/* Program the isrg regs only if number of grps > 1 */
 	if (priv->num_grps > 1) {

^ permalink raw reply related

* [net-next patch] bnx2x: Add run-time CNIC support
From: Merav Sicron @ 2012-07-08  9:48 UTC (permalink / raw)
  To: davem, netdev, eilong; +Cc: Merav Sicron, Dmitry Kravkov

This patch replaces the BCM_CNIC compilation flag with a run-time flag.
This is mainly important for the SR-IOV driver, as this driver will share the
same code with the PF/hypervisor driver. Since storage is not supported in
SR-IOV (while is usually enabled in the non-SR-IOV driver), we don't want to
waste resources on it.
In addition this change makes the code prettier.

Signed-off-by: Merav Sicron <meravs@broadcom.com>
Signed-off-by: Dmitry Kravkov <dmitry@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
---
Hi Dave,

Please consider applying this patch to net-next.

Thanks,
Merav

 drivers/net/ethernet/broadcom/bnx2x/bnx2x.h        |   74 +--
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c    |  179 +++---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h    |   17 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c    |    9 +-
 .../net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c    |    4 +-
 .../net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h   |    2 -
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c   |  579 ++++++++++----------
 7 files changed, 396 insertions(+), 468 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index 362d16f..53f2cb8 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -34,18 +34,10 @@

 #include "bnx2x_hsi.h"

-#if defined(CONFIG_CNIC) || defined(CONFIG_CNIC_MODULE)
-#define BCM_CNIC 1
 #include "../cnic_if.h"
-#endif

-#ifdef BCM_CNIC
-#define BNX2X_MIN_MSIX_VEC_CNT 3
-#define BNX2X_MSIX_VEC_FP_START 2
-#else
-#define BNX2X_MIN_MSIX_VEC_CNT 2
-#define BNX2X_MSIX_VEC_FP_START 1
-#endif
+
+#define BNX2X_MIN_MSIX_VEC_CNT(bp)		((bp)->min_msix_vec_cnt)

 #include <linux/mdio.h>

@@ -251,20 +243,13 @@ enum {

 #define BNX2X_CNIC_START_ETH_CID(bp)	(BNX2X_NUM_NON_CNIC_QUEUES(bp) *\
 					 (bp)->max_cos)
+
 	/* iSCSI L2 */
 #define	BNX2X_ISCSI_ETH_CID(bp)		(BNX2X_CNIC_START_ETH_CID(bp))
 	/* FCoE L2 */
 #define	BNX2X_FCOE_ETH_CID(bp)		(BNX2X_CNIC_START_ETH_CID(bp) + 1)

-/** Additional rings budgeting */
-#ifdef BCM_CNIC
-#define CNIC_PRESENT			1
-#define FCOE_PRESENT			1
-#else
-#define CNIC_PRESENT			0
-#define FCOE_PRESENT			0
-#endif /* BCM_CNIC */
-#define NON_ETH_CONTEXT_USE	(FCOE_PRESENT)
+#define CNIC_ENABLED(bp)		((bp)->cnic_enabled)

 #define AEU_IN_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR \
 	AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR
@@ -297,9 +282,7 @@ enum {
 	OOO_TXQ_IDX_OFFSET,
 };
 #define MAX_ETH_TXQ_IDX(bp)	(BNX2X_NUM_NON_CNIC_QUEUES(bp) * (bp)->max_cos)
-#ifdef BCM_CNIC
 #define FCOE_TXQ_IDX(bp)	(MAX_ETH_TXQ_IDX(bp) + FCOE_TXQ_IDX_OFFSET)
-#endif

 /* fast path */
 /*
@@ -584,15 +567,10 @@ struct bnx2x_fastpath {
 						->var)


-#define IS_ETH_FP(fp)			(fp->index < \
-					 BNX2X_NUM_ETH_QUEUES(fp->bp))
-#ifdef BCM_CNIC
-#define IS_FCOE_FP(fp)			(fp->index == FCOE_IDX(fp->bp))
-#define IS_FCOE_IDX(idx)		((idx) == FCOE_IDX(bp))
-#else
-#define IS_FCOE_FP(fp)		false
-#define IS_FCOE_IDX(idx)	false
-#endif
+#define IS_ETH_FP(fp)		((fp)->index < BNX2X_NUM_ETH_QUEUES((fp)->bp))
+#define IS_FCOE_FP(fp)		((fp)->index == FCOE_IDX((fp)->bp) && \
+					       CNIC_ENABLED((fp)->bp))
+#define IS_FCOE_IDX(idx)	(CNIC_ENABLED(bp) && ((idx) == FCOE_IDX(bp)))


 /* MC hsi */
@@ -979,18 +957,15 @@ union cdu_context {
 #define CDU_ILT_PAGE_SZ		(8192 << CDU_ILT_PAGE_SZ_HW) /* 32K */
 #define ILT_PAGE_CIDS		(CDU_ILT_PAGE_SZ / sizeof(union cdu_context))

-#ifdef BCM_CNIC
 #define CNIC_ISCSI_CID_MAX	256
 #define CNIC_FCOE_CID_MAX	2048
 #define CNIC_CID_MAX		(CNIC_ISCSI_CID_MAX + CNIC_FCOE_CID_MAX)
 #define CNIC_ILT_LINES		DIV_ROUND_UP(CNIC_CID_MAX, ILT_PAGE_CIDS)
-#endif

 #define QM_ILT_PAGE_SZ_HW	0
 #define QM_ILT_PAGE_SZ		(4096 << QM_ILT_PAGE_SZ_HW) /* 4K */
 #define QM_CID_ROUND		1024

-#ifdef BCM_CNIC
 /* TM (timers) host DB constants */
 #define TM_ILT_PAGE_SZ_HW	0
 #define TM_ILT_PAGE_SZ		(4096 << TM_ILT_PAGE_SZ_HW) /* 4K */
@@ -1008,8 +983,6 @@ union cdu_context {
 #define SRC_T2_SZ		SRC_ILT_SZ
 #define SRC_ILT_LINES		DIV_ROUND_UP(SRC_ILT_SZ, SRC_ILT_PAGE_SZ)

-#endif
-
 #define MAX_DMAE_C		8

 /* DMA memory not used in fastpath */
@@ -1203,7 +1176,6 @@ struct bnx2x {
 	struct bnx2x_sp_objs	*sp_objs;
 	struct bnx2x_fp_stats	*fp_stats;
 	struct bnx2x_fp_txdata	*bnx2x_txq;
-	int			bnx2x_txq_size;
 	void __iomem		*regview;
 	void __iomem		*doorbells;
 	u16			db_size;
@@ -1326,6 +1298,8 @@ struct bnx2x {
 #define NO_ISCSI_OOO(bp)	((bp)->flags & NO_ISCSI_OOO_FLAG)
 #define NO_FCOE(bp)		((bp)->flags & NO_FCOE_FLAG)

+	int			cnic_enabled;
+
 	int			pm_cap;
 	int			mrrs;

@@ -1396,6 +1370,9 @@ struct bnx2x {
 #define BNX2X_MAX_COS			3
 #define BNX2X_MAX_TX_COS		2
 	int			num_queues;
+	uint			num_ethernet_queues;
+	uint			num_cnic_queues;
+	/* The number of queues to whom MSI-X vector and napi was allocated */
 	int			num_napi_queues;
 	int			disable_tpa;

@@ -1409,6 +1386,7 @@ struct bnx2x {
 	u8			igu_dsb_id;
 	u8			igu_base_sb;
 	u8			igu_sb_cnt;
+	u8			min_msix_vec_cnt;

 	dma_addr_t		def_status_blk_mapping;

@@ -1454,16 +1432,16 @@ struct bnx2x {
  * Maximum supported number of RSS queues: number of IGU SBs minus one that goes
  * to CNIC.
  */
-#define BNX2X_MAX_RSS_COUNT(bp)	((bp)->igu_sb_cnt - CNIC_PRESENT)
+#define BNX2X_MAX_RSS_COUNT(bp)	((bp)->igu_sb_cnt - CNIC_ENABLED(bp))

 /*
  * Maximum CID count that might be required by the bnx2x:
  * Max RSS * Max_Tx_Multi_Cos + FCoE + iSCSI
  */
 #define BNX2X_L2_CID_COUNT(bp)	(BNX2X_NUM_ETH_QUEUES(bp) * BNX2X_MULTI_TX_COS \
-				+ NON_ETH_CONTEXT_USE + CNIC_PRESENT)
+				+ 2 * CNIC_ENABLED(bp))
 #define BNX2X_L2_MAX_CID(bp)	(BNX2X_MAX_RSS_COUNT(bp) * BNX2X_MULTI_TX_COS \
-				+ NON_ETH_CONTEXT_USE + CNIC_PRESENT)
+				+ 2 * CNIC_ENABLED(bp))
 #define L2_ILT_LINES(bp)	(DIV_ROUND_UP(BNX2X_L2_CID_COUNT(bp),\
 					ILT_PAGE_CIDS))

@@ -1471,9 +1449,6 @@ struct bnx2x {

 	int			dropless_fc;

-#ifdef BCM_CNIC
-	u32			cnic_flags;
-#define BNX2X_CNIC_FLAG_MAC_SET		1
 	void			*t2;
 	dma_addr_t		t2_mapping;
 	struct cnic_ops	__rcu	*cnic_ops;
@@ -1494,7 +1469,6 @@ struct bnx2x {

 	/* Start index of the "special" (CNIC related) L2 cleints */
 	u8				cnic_base_cl_id;
-#endif

 	int			dmae_ready;
 	/* used to synchronize dmae accesses */
@@ -1623,9 +1597,10 @@ struct bnx2x {
 /* Tx queues may be less or equal to Rx queues */
 extern int num_queues;
 #define BNX2X_NUM_QUEUES(bp)	(bp->num_queues)
-#define BNX2X_NUM_ETH_QUEUES(bp) (BNX2X_NUM_QUEUES(bp) - NON_ETH_CONTEXT_USE)
+#define BNX2X_INIT_NUM_QUEUES(bp)	((bp)->init_num_queues)
+#define BNX2X_NUM_ETH_QUEUES(bp) ((bp)->num_ethernet_queues)
 #define BNX2X_NUM_NON_CNIC_QUEUES(bp)	(BNX2X_NUM_QUEUES(bp) - \
-					 NON_ETH_CONTEXT_USE)
+					 (bp)->num_cnic_queues)
 #define BNX2X_NUM_RX_QUEUES(bp)	BNX2X_NUM_QUEUES(bp)

 #define is_multi(bp)		(BNX2X_NUM_QUEUES(bp) > 1)
@@ -2167,7 +2142,6 @@ void bnx2x_notify_link_changed(struct bnx2x *bp);
 #define BNX2X_MF_SD_PROTOCOL(bp) \
 	((bp)->mf_config[BP_VN(bp)] & FUNC_MF_CFG_PROTOCOL_MASK)

-#ifdef BCM_CNIC
 #define BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp) \
 	(BNX2X_MF_SD_PROTOCOL(bp) == FUNC_MF_CFG_PROTOCOL_ISCSI)

@@ -2180,13 +2154,13 @@ void bnx2x_notify_link_changed(struct bnx2x *bp);
 #define BNX2X_MF_EXT_PROTOCOL_FCOE(bp)  ((bp)->mf_ext_config & \
 					 MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD)

-#define IS_MF_FCOE_AFEX(bp) (IS_MF_AFEX(bp) && BNX2X_MF_EXT_PROTOCOL_FCOE(bp))
+#define IS_MF_FCOE_AFEX(bp) (IS_MF_AFEX(bp) && \
+			     BNX2X_MF_EXT_PROTOCOL_FCOE(bp) && CNIC_ENABLED(bp))
+
 #define IS_MF_STORAGE_SD(bp) (IS_MF_SD(bp) && \
 				(BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp) || \
 				 BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp)))
-#else
-#define IS_MF_FCOE_AFEX(bp)	false
-#endif
+


 #endif /* bnx2x.h */
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 00951b3..8ac94b8 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -1334,11 +1334,11 @@ static void bnx2x_free_msix_irqs(struct bnx2x *bp, int nvecs)
 	DP(NETIF_MSG_IFDOWN, "released sp irq (%d)\n",
 	   bp->msix_table[offset].vector);
 	offset++;
-#ifdef BCM_CNIC
-	if (nvecs == offset)
-		return;
-	offset++;
-#endif
+	if (CNIC_ENABLED(bp)) {
+		if (nvecs == offset)
+			return;
+		offset++;
+	}

 	for_each_eth_queue(bp, i) {
 		if (nvecs == offset)
@@ -1355,7 +1355,7 @@ void bnx2x_free_irq(struct bnx2x *bp)
 	if (bp->flags & USING_MSIX_FLAG &&
 	    !(bp->flags & USING_SINGLE_MSIX_FLAG))
 		bnx2x_free_msix_irqs(bp, BNX2X_NUM_ETH_QUEUES(bp) +
-				     CNIC_PRESENT + 1);
+				     CNIC_ENABLED(bp) + 1);
 	else
 		free_irq(bp->dev->irq, bp->dev);
 }
@@ -1369,12 +1369,14 @@ int bnx2x_enable_msix(struct bnx2x *bp)
 	   bp->msix_table[0].entry);
 	msix_vec++;

-#ifdef BCM_CNIC
-	bp->msix_table[msix_vec].entry = msix_vec;
-	BNX2X_DEV_INFO("msix_table[%d].entry = %d (CNIC)\n",
-	   bp->msix_table[msix_vec].entry, bp->msix_table[msix_vec].entry);
-	msix_vec++;
-#endif
+
+	if (CNIC_ENABLED(bp)) {
+		bp->msix_table[msix_vec].entry = msix_vec;
+		BNX2X_DEV_INFO("msix_table[%d].entry = %d (CNIC)\n",
+			       msix_vec, bp->msix_table[msix_vec].entry);
+		msix_vec++;
+	}
+
 	/* We need separate vectors for ETH queues only (not FCoE) */
 	for_each_eth_queue(bp, i) {
 		bp->msix_table[msix_vec].entry = msix_vec;
@@ -1383,7 +1385,7 @@ int bnx2x_enable_msix(struct bnx2x *bp)
 		msix_vec++;
 	}

-	req_cnt = BNX2X_NUM_ETH_QUEUES(bp) + CNIC_PRESENT + 1;
+	req_cnt = BNX2X_NUM_ETH_QUEUES(bp) + CNIC_ENABLED(bp) + 1;

 	rc = pci_enable_msix(bp->pdev, &bp->msix_table[0], req_cnt);

@@ -1391,7 +1393,7 @@ int bnx2x_enable_msix(struct bnx2x *bp)
 	 * reconfigure number of tx/rx queues according to available
 	 * MSI-X vectors
 	 */
-	if (rc >= BNX2X_MIN_MSIX_VEC_CNT) {
+	if (rc >= BNX2X_MIN_MSIX_VEC_CNT(bp)) {
 		/* how less vectors we will have? */
 		int diff = req_cnt - rc;

@@ -1406,7 +1408,8 @@ int bnx2x_enable_msix(struct bnx2x *bp)
 		/*
 		 * decrease number of queues by number of unallocated entries
 		 */
-		bp->num_queues -= diff;
+		bp->num_ethernet_queues -= diff;
+		bp->num_queues = bp->num_ethernet_queues + bp->num_cnic_queues;

 		BNX2X_DEV_INFO("New queue configuration set: %d\n",
 			       bp->num_queues);
@@ -1451,9 +1454,9 @@ static int bnx2x_req_msix_irqs(struct bnx2x *bp)
 		return -EBUSY;
 	}

-#ifdef BCM_CNIC
-	offset++;
-#endif
+	if (CNIC_ENABLED(bp))
+		offset++;
+
 	for_each_eth_queue(bp, i) {
 		struct bnx2x_fastpath *fp = &bp->fp[i];
 		snprintf(fp->name, sizeof(fp->name), "%s-fp-%d",
@@ -1472,7 +1475,7 @@ static int bnx2x_req_msix_irqs(struct bnx2x *bp)
 	}

 	i = BNX2X_NUM_ETH_QUEUES(bp);
-	offset = 1 + CNIC_PRESENT;
+	offset = 1 + CNIC_ENABLED(bp);
 	netdev_info(bp->dev, "using MSI-X  IRQs: sp %d  fp[%d] %d ... fp[%d] %d\n",
 	       bp->msix_table[0].vector,
 	       0, bp->msix_table[offset].vector,
@@ -1579,7 +1582,6 @@ u16 bnx2x_select_queue(struct net_device *dev, struct sk_buff *skb)
 {
 	struct bnx2x *bp = netdev_priv(dev);

-#ifdef BCM_CNIC
 	if (!NO_FCOE(bp)) {
 		struct ethhdr *hdr = (struct ethhdr *)skb->data;
 		u16 ether_type = ntohs(hdr->h_proto);
@@ -1596,7 +1598,7 @@ u16 bnx2x_select_queue(struct net_device *dev, struct sk_buff *skb)
 		if ((ether_type == ETH_P_FCOE) || (ether_type == ETH_P_FIP))
 			return bnx2x_fcoe_tx(bp, txq_index);
 	}
-#endif
+
 	/* select a non-FCoE queue */
 	return __skb_tx_hash(dev, skb, BNX2X_NUM_ETH_QUEUES(bp));
 }
@@ -1605,15 +1607,16 @@ u16 bnx2x_select_queue(struct net_device *dev, struct sk_buff *skb)
 void bnx2x_set_num_queues(struct bnx2x *bp)
 {
 	/* RSS queues */
-	bp->num_queues = bnx2x_calc_num_queues(bp);
+	bp->num_ethernet_queues = bnx2x_calc_num_queues(bp);

-#ifdef BCM_CNIC
 	/* override in STORAGE SD modes */
-	if (IS_MF_STORAGE_SD(bp) || IS_MF_FCOE_AFEX(bp))
-		bp->num_queues = 1;
-#endif
+	if (CNIC_ENABLED(bp) && (IS_MF_STORAGE_SD(bp) || IS_MF_FCOE_AFEX(bp)))
+		bp->num_ethernet_queues = 1;
+
 	/* Add special queues */
-	bp->num_queues += NON_ETH_CONTEXT_USE;
+	bp->num_cnic_queues = CNIC_ENABLED(bp); /* For FCOE */
+
+	bp->num_queues = bp->num_ethernet_queues + bp->num_cnic_queues;

 	BNX2X_DEV_INFO("set number of queues to %d\n", bp->num_queues);
 }
@@ -1645,15 +1648,13 @@ static int bnx2x_set_real_num_queues(struct bnx2x *bp)
 	int rc, tx, rx;

 	tx = BNX2X_NUM_ETH_QUEUES(bp) * bp->max_cos;
-	rx = BNX2X_NUM_QUEUES(bp) - NON_ETH_CONTEXT_USE;
+	rx = BNX2X_NUM_ETH_QUEUES(bp);

 /* account for fcoe queue */
-#ifdef BCM_CNIC
 	if (!NO_FCOE(bp)) {
-		rx += FCOE_PRESENT;
-		tx += FCOE_PRESENT;
+		rx++;
+		tx++;
 	}
-#endif

 	rc = netif_set_real_num_tx_queues(bp->dev, tx);
 	if (rc) {
@@ -1946,10 +1947,8 @@ static void bnx2x_bz_fp(struct bnx2x *bp, int index)
 		fp->max_cos = 1;

 	/* Init txdata pointers */
-#ifdef BCM_CNIC
 	if (IS_FCOE_FP(fp))
 		fp->txdata_ptr[0] = &bp->bnx2x_txq[FCOE_TXQ_IDX(bp)];
-#endif
 	if (IS_ETH_FP(fp))
 		for_each_cos_in_tx_queue(fp, cos)
 			fp->txdata_ptr[cos] = &bp->bnx2x_txq[cos *
@@ -1967,14 +1966,12 @@ static void bnx2x_bz_fp(struct bnx2x *bp, int index)
 	else if (bp->flags & GRO_ENABLE_FLAG)
 		fp->mode = TPA_MODE_GRO;

-#ifdef BCM_CNIC
+
 	/* We don't want TPA on an FCoE L2 ring */
 	if (IS_FCOE_FP(fp))
 		fp->disable_tpa = 1;
-#endif
 }

-
 /* must be called with rtnl_lock */
 int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
 {
@@ -2009,8 +2006,9 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
 	DP(NETIF_MSG_IFUP, "num queues: %d", bp->num_queues);
 	for_each_queue(bp, i)
 		bnx2x_bz_fp(bp, i);
-	memset(bp->bnx2x_txq, 0, bp->bnx2x_txq_size *
-	       sizeof(struct bnx2x_fp_txdata));
+	memset(bp->bnx2x_txq, 0, (BNX2X_MAX_RSS_COUNT(bp) * BNX2X_MULTI_TX_COS +
+				  bp->num_cnic_queues) *
+				  sizeof(struct bnx2x_fp_txdata));


 	/* Set the receive queues buffer size */
@@ -2176,10 +2174,9 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
 		LOAD_ERROR_EXIT(bp, load_error3);
 	}

-#ifdef BCM_CNIC
-	/* Enable Timer scan */
-	REG_WR(bp, TM_REG_EN_LINEAR0_TIMER + port*4, 1);
-#endif
+	if (CNIC_ENABLED(bp))
+		/* Enable Timer scan */
+		REG_WR(bp, TM_REG_EN_LINEAR0_TIMER + port*4, 1);

 	for_each_nondefault_queue(bp, i) {
 		rc = bnx2x_setup_queue(bp, &bp->fp[i], 0);
@@ -2249,14 +2246,14 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
 	/* start the timer */
 	mod_timer(&bp->timer, jiffies + bp->current_interval);

-#ifdef BCM_CNIC
-	/* re-read iscsi info */
-	bnx2x_get_iscsi_info(bp);
-	bnx2x_setup_cnic_irq_info(bp);
-	bnx2x_setup_cnic_info(bp);
-	if (bp->state == BNX2X_STATE_OPEN)
-		bnx2x_cnic_notify(bp, CNIC_CTL_START_CMD);
-#endif
+	if (CNIC_ENABLED(bp)) {
+		/* re-read iscsi info */
+		bnx2x_get_iscsi_info(bp);
+		bnx2x_setup_cnic_irq_info(bp);
+		bnx2x_setup_cnic_info(bp);
+		if (bp->state == BNX2X_STATE_OPEN)
+			bnx2x_cnic_notify(bp, CNIC_CTL_START_CMD);
+	}

 	/* mark driver is loaded in shmem2 */
 	if (SHMEM2_HAS(bp, drv_capabilities_flag)) {
@@ -2282,10 +2279,9 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)

 #ifndef BNX2X_STOP_ON_ERROR
 load_error4:
-#ifdef BCM_CNIC
-	/* Disable Timer scan */
-	REG_WR(bp, TM_REG_EN_LINEAR0_TIMER + port*4, 0);
-#endif
+	if (CNIC_ENABLED(bp))
+		/* Disable Timer scan */
+		REG_WR(bp, TM_REG_EN_LINEAR0_TIMER + port*4, 0);
 load_error3:
 	bnx2x_int_disable_sync(bp, 1);

@@ -2362,9 +2358,8 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode)
 	bnx2x_tx_disable(bp);
 	netdev_reset_tc(bp->dev);

-#ifdef BCM_CNIC
-	bnx2x_cnic_notify(bp, CNIC_CTL_STOP_CMD);
-#endif
+	if (CNIC_ENABLED(bp))
+		bnx2x_cnic_notify(bp, CNIC_CTL_STOP_CMD);

 	bp->rx_mode = BNX2X_RX_MODE_NONE;

@@ -2533,7 +2528,7 @@ int bnx2x_poll(struct napi_struct *napi, int budget)

 		/* Fall out from the NAPI loop if needed */
 		if (!(bnx2x_has_rx_work(fp) || bnx2x_has_tx_work(fp))) {
-#ifdef BCM_CNIC
+
 			/* No need to update SB for FCoE L2 ring as long as
 			 * it's connected to the default SB and the SB
 			 * has been updated when NAPI was scheduled.
@@ -2542,7 +2537,6 @@ int bnx2x_poll(struct napi_struct *napi, int budget)
 				napi_complete(napi);
 				break;
 			}
-#endif

 			bnx2x_update_fpsb_idx(fp);
 			/* bnx2x_has_rx_work() reads the status block,
@@ -2923,7 +2917,7 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	txq_index = skb_get_queue_mapping(skb);
 	txq = netdev_get_tx_queue(dev, txq_index);

-	BUG_ON(txq_index >= MAX_ETH_TXQ_IDX(bp) + FCOE_PRESENT);
+	BUG_ON(txq_index >= MAX_ETH_TXQ_IDX(bp) + CNIC_ENABLED(bp));

 	txdata = &bp->bnx2x_txq[txq_index];

@@ -3308,13 +3302,11 @@ int bnx2x_change_mac_addr(struct net_device *dev, void *p)
 		return -EINVAL;
 	}

-#ifdef BCM_CNIC
-	if ((IS_MF_STORAGE_SD(bp) || IS_MF_FCOE_AFEX(bp)) &&
+	if (CNIC_ENABLED(bp) && (IS_MF_STORAGE_SD(bp) || IS_MF_FCOE_AFEX(bp)) &&
 	    !is_zero_ether_addr(addr->sa_data)) {
 		BNX2X_ERR("Can't configure non-zero address on iSCSI or FCoE functions in MF-SD mode\n");
 		return -EINVAL;
 	}
-#endif

 	if (netif_running(dev))  {
 		rc = bnx2x_set_eth_mac(bp, false);
@@ -3338,13 +3330,11 @@ static void bnx2x_free_fp_mem_at(struct bnx2x *bp, int fp_index)
 	u8 cos;

 	/* Common */
-#ifdef BCM_CNIC
+
 	if (IS_FCOE_IDX(fp_index)) {
 		memset(sb, 0, sizeof(union host_hc_status_block));
 		fp->status_blk_mapping = 0;
-
 	} else {
-#endif
 		/* status blocks */
 		if (!CHIP_IS_E1x(bp))
 			BNX2X_PCI_FREE(sb->e2_sb,
@@ -3356,9 +3346,8 @@ static void bnx2x_free_fp_mem_at(struct bnx2x *bp, int fp_index)
 				       bnx2x_fp(bp, fp_index,
 						status_blk_mapping),
 				       sizeof(struct host_hc_status_block_e1x));
-#ifdef BCM_CNIC
 	}
-#endif
+
 	/* Rx */
 	if (!skip_rx_queue(bp, fp_index)) {
 		bnx2x_free_rx_bds(fp);
@@ -3488,14 +3477,11 @@ static int bnx2x_alloc_fp_mem_at(struct bnx2x *bp, int index)
 	u8 cos;
 	int rx_ring_size = 0;

-#ifdef BCM_CNIC
-	if (!bp->rx_ring_size &&
+	if (CNIC_ENABLED(bp) && !bp->rx_ring_size &&
 	    (IS_MF_STORAGE_SD(bp) || IS_MF_FCOE_AFEX(bp))) {
 		rx_ring_size = MIN_RX_SIZE_NONTPA;
 		bp->rx_ring_size = rx_ring_size;
-	} else
-#endif
-	if (!bp->rx_ring_size) {
+	} else if (!bp->rx_ring_size) {
 		u32 cfg = SHMEM_RD(bp,
 			     dev_info.port_hw_config[BP_PORT(bp)].default_cfg);

@@ -3516,9 +3502,8 @@ static int bnx2x_alloc_fp_mem_at(struct bnx2x *bp, int index)

 	/* Common */
 	sb = &bnx2x_fp(bp, index, status_blk);
-#ifdef BCM_CNIC
+
 	if (!IS_FCOE_IDX(index)) {
-#endif
 		/* status blocks */
 		if (!CHIP_IS_E1x(bp))
 			BNX2X_PCI_ALLOC(sb->e2_sb,
@@ -3528,9 +3513,7 @@ static int bnx2x_alloc_fp_mem_at(struct bnx2x *bp, int index)
 			BNX2X_PCI_ALLOC(sb->e1x_sb,
 				&bnx2x_fp(bp, index, status_blk_mapping),
 			    sizeof(struct host_hc_status_block_e1x));
-#ifdef BCM_CNIC
 	}
-#endif

 	/* FCoE Queue uses Default SB and doesn't ACK the SB, thus no need to
 	 * set shortcuts for it.
@@ -3622,7 +3605,6 @@ int bnx2x_alloc_fp_mem(struct bnx2x *bp)
 	if (bnx2x_alloc_fp_mem_at(bp, 0))
 		return -ENOMEM;

-#ifdef BCM_CNIC
 	if (!NO_FCOE(bp))
 		/* FCoE */
 		if (bnx2x_alloc_fp_mem_at(bp, FCOE_IDX(bp)))
@@ -3630,7 +3612,6 @@ int bnx2x_alloc_fp_mem(struct bnx2x *bp)
 			 * NO_FCOE_FLAG
 			 */
 			return -ENOMEM;
-#endif

 	/* RSS */
 	for_each_nondefault_eth_queue(bp, i)
@@ -3642,17 +3623,18 @@ int bnx2x_alloc_fp_mem(struct bnx2x *bp)
 		int delta = BNX2X_NUM_ETH_QUEUES(bp) - i;

 		WARN_ON(delta < 0);
-#ifdef BCM_CNIC
-		/**
-		 * move non eth FPs next to last eth FP
-		 * must be done in that order
-		 * FCOE_IDX < FWD_IDX < OOO_IDX
-		 */
+		if (CNIC_ENABLED(bp))
+			/**
+			 * move non eth FPs next to last eth FP
+			 * must be done in that order
+			 * FCOE_IDX < FWD_IDX < OOO_IDX
+			 */

-		/* move FCoE fp even NO_FCOE_FLAG is on */
-		bnx2x_move_fp(bp, FCOE_IDX(bp), FCOE_IDX(bp) - delta);
-#endif
-		bp->num_queues -= delta;
+			/* move FCoE fp even NO_FCOE_FLAG is on */
+			bnx2x_move_fp(bp, FCOE_IDX(bp), FCOE_IDX(bp) - delta);
+		bp->num_ethernet_queues -= delta;
+		bp->num_queues = bp->num_ethernet_queues +
+				 bp->num_cnic_queues;
 		BNX2X_ERR("Adjusted num of queues from %d to %d\n",
 			  bp->num_queues + delta, bp->num_queues);
 	}
@@ -3677,7 +3659,7 @@ int __devinit bnx2x_alloc_mem_bp(struct bnx2x *bp)
 	struct msix_entry *tbl;
 	struct bnx2x_ilt *ilt;
 	int msix_table_size = 0;
-	int fp_array_size;
+	int fp_array_size, txq_array_size;
 	int i;

 	/*
@@ -3687,8 +3669,7 @@ int __devinit bnx2x_alloc_mem_bp(struct bnx2x *bp)
 	msix_table_size = bp->igu_sb_cnt + 1;

 	/* fp array: RSS plus CNIC related L2 queues */
-	fp_array_size = BNX2X_MAX_RSS_COUNT(bp) + NON_ETH_CONTEXT_USE;
-	BNX2X_DEV_INFO("fp_array_size %d", fp_array_size);
+	fp_array_size = BNX2X_MAX_RSS_COUNT(bp) + CNIC_ENABLED(bp);

 	fp = kcalloc(fp_array_size, sizeof(*fp), GFP_KERNEL);
 	if (!fp)
@@ -3716,12 +3697,10 @@ int __devinit bnx2x_alloc_mem_bp(struct bnx2x *bp)
 		goto alloc_err;

 	/* Allocate memory for the transmission queues array */
-	bp->bnx2x_txq_size = BNX2X_MAX_RSS_COUNT(bp) * BNX2X_MULTI_TX_COS;
-#ifdef BCM_CNIC
-	bp->bnx2x_txq_size++;
-#endif
-	bp->bnx2x_txq = kcalloc(bp->bnx2x_txq_size,
-				sizeof(struct bnx2x_fp_txdata), GFP_KERNEL);
+	txq_array_size = BNX2X_MAX_RSS_COUNT(bp) * BNX2X_MULTI_TX_COS +
+			 CNIC_ENABLED(bp);
+	bp->bnx2x_txq = kcalloc(txq_array_size, sizeof(struct bnx2x_fp_txdata),
+				GFP_KERNEL);
 	if (!bp->bnx2x_txq)
 		goto alloc_err;

@@ -3804,7 +3783,7 @@ int bnx2x_get_link_cfg_idx(struct bnx2x *bp)
 	return LINK_CONFIG_IDX(sel_phy_idx);
 }

-#if defined(NETDEV_FCOE_WWNN) && defined(BCM_CNIC)
+#ifdef NETDEV_FCOE_WWNN
 int bnx2x_fcoe_get_wwn(struct net_device *dev, u64 *wwn, int type)
 {
 	struct bnx2x *bp = netdev_priv(dev);
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
index 53659f3..46068e5 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
@@ -229,7 +229,6 @@ irqreturn_t bnx2x_msix_sp_int(int irq, void *dev_instance);
  * @dev_instance:	private instance
  */
 irqreturn_t bnx2x_interrupt(int irq, void *dev_instance);
-#ifdef BCM_CNIC

 /**
  * bnx2x_cnic_notify - send command to cnic driver
@@ -253,8 +252,6 @@ void bnx2x_setup_cnic_irq_info(struct bnx2x *bp);
  */
 void bnx2x_setup_cnic_info(struct bnx2x *bp);

-#endif
-
 /**
  * bnx2x_int_enable - enable HW interrupts.
  *
@@ -537,7 +534,7 @@ void bnx2x_free_mem_bp(struct bnx2x *bp);
  */
 int bnx2x_change_mtu(struct net_device *dev, int new_mtu);

-#if defined(NETDEV_FCOE_WWNN) && defined(BCM_CNIC)
+#ifdef NETDEV_FCOE_WWNN
 /**
  * bnx2x_fcoe_get_wwn - return the requested WWN value for this port
  *
@@ -971,11 +968,9 @@ static inline u8 bnx2x_stats_id(struct bnx2x_fastpath *fp)
 {
 	struct bnx2x *bp = fp->bp;
 	if (!CHIP_IS_E1x(bp)) {
-#ifdef BCM_CNIC
 		/* there are special statistics counters for FCoE 136..140 */
 		if (IS_FCOE_FP(fp))
 			return bp->cnic_base_cl_id + (bp->pf_num >> 1);
-#endif
 		return fp->cl_id;
 	}
 	return fp->cl_id + BP_PORT(bp) * FP_SB_MAX_E1x;
@@ -1093,7 +1088,6 @@ static inline void bnx2x_init_txdata(struct bnx2x *bp,
 	   txdata->cid, txdata->txq_index);
 }

-#ifdef BCM_CNIC
 static inline u8 bnx2x_cnic_eth_cl_id(struct bnx2x *bp, u8 cl_idx)
 {
 	return bp->cnic_base_cl_id + cl_idx +
@@ -1153,7 +1147,6 @@ static inline void bnx2x_init_fcoe_fp(struct bnx2x *bp)
 	   fp->index, bp, fp->status_blk.e2_sb, fp->cl_id, fp->fw_sb_id,
 	   fp->igu_sb_id);
 }
-#endif

 static inline int bnx2x_clean_tx_queue(struct bnx2x *bp,
 				       struct bnx2x_fp_txdata *txdata)
@@ -1271,7 +1264,7 @@ static inline bool bnx2x_mtu_allows_gro(int mtu)
 	 */
 	return mtu <= SGE_PAGE_SIZE && (U_ETH_SGL_SIZE * fpp) <= MAX_SKB_FRAGS;
 }
-#ifdef BCM_CNIC
+
 /**
  * bnx2x_get_iscsi_info - update iSCSI params according to licensing info.
  *
@@ -1279,7 +1272,6 @@ static inline bool bnx2x_mtu_allows_gro(int mtu)
  *
  */
 void bnx2x_get_iscsi_info(struct bnx2x *bp);
-#endif

 /**
  * bnx2x_link_sync_notify - send notification to other functions.
@@ -1333,11 +1325,10 @@ static inline bool bnx2x_is_valid_ether_addr(struct bnx2x *bp, u8 *addr)
 {
 	if (is_valid_ether_addr(addr))
 		return true;
-#ifdef BCM_CNIC
-	if (is_zero_ether_addr(addr) &&
+	if (CNIC_ENABLED(bp) && is_zero_ether_addr(addr) &&
 	    (IS_MF_STORAGE_SD(bp) || IS_MF_FCOE_AFEX(bp)))
 		return true;
-#endif
+
 	return false;
 }

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
index 8a73374..c0f4432 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
@@ -1912,10 +1912,11 @@ static void bnx2x_dcbnl_get_perm_hw_addr(struct net_device *netdev,
 	/* first the HW mac address */
 	memcpy(perm_addr, netdev->dev_addr, netdev->addr_len);

-#ifdef BCM_CNIC
-	/* second SAN address */
-	memcpy(perm_addr+netdev->addr_len, bp->fip_mac, netdev->addr_len);
-#endif
+
+	if (CNIC_ENABLED(bp))
+		/* second SAN address */
+		memcpy(perm_addr+netdev->addr_len, bp->fip_mac,
+		       netdev->addr_len);
 }

 static void bnx2x_dcbnl_set_pg_tccfg_tx(struct net_device *netdev, int prio,
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
index bff3129..a384a8d 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
@@ -2890,7 +2890,9 @@ static void bnx2x_change_num_queues(struct bnx2x *bp, int num_rss)
 {
 	bnx2x_del_all_napi(bp);
 	bnx2x_disable_msi(bp);
-	BNX2X_NUM_QUEUES(bp) = num_rss + NON_ETH_CONTEXT_USE;
+	bp->num_ethernet_queues = num_rss;
+	bp->num_queues = bp->num_ethernet_queues + bp->num_cnic_queues;
+	BNX2X_DEV_INFO("set number of queues to %d\n", bp->num_queues);
 	bnx2x_set_int_mode(bp);
 	bnx2x_add_all_napi(bp);
 }
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h
index fe66d90..e1e66f0 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h
@@ -890,7 +890,6 @@ static void bnx2x_qm_init_ptr_table(struct bnx2x *bp, int qm_cid_count,
 /****************************************************************************
 * SRC initializations
 ****************************************************************************/
-#ifdef BCM_CNIC
 /* called during init func stage */
 static void bnx2x_src_init_t2(struct bnx2x *bp, struct src_ent *t2,
 			      dma_addr_t t2_mapping, int src_cid_count)
@@ -915,5 +914,4 @@ static void bnx2x_src_init_t2(struct bnx2x *bp, struct src_ent *t2,
 		    U64_HI((u64)t2_mapping +
 			   (src_cid_count-1) * sizeof(struct src_ent)));
 }
-#endif
 #endif /* BNX2X_INIT_OPS_H */
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 5b8b521..22912ca 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -773,10 +773,9 @@ void bnx2x_panic_dump(struct bnx2x *bp)

 		/* host sb data */

-#ifdef BCM_CNIC
 		if (IS_FCOE_FP(fp))
 			continue;
-#endif
+
 		BNX2X_ERR("     run indexes (");
 		for (j = 0; j < HC_SB_MAX_SM; j++)
 			pr_cont("0x%x%s",
@@ -1491,9 +1490,9 @@ void bnx2x_int_disable_sync(struct bnx2x *bp, int disable_hw)
 	if (msix) {
 		synchronize_irq(bp->msix_table[0].vector);
 		offset = 1;
-#ifdef BCM_CNIC
-		offset++;
-#endif
+
+		if (CNIC_ENABLED(bp))
+			offset++;
 		for_each_eth_queue(bp, i)
 			synchronize_irq(bp->msix_table[offset++].vector);
 	} else
@@ -1575,9 +1574,7 @@ static bool bnx2x_trylock_leader_lock(struct bnx2x *bp)
 	return bnx2x_trylock_hw_lock(bp, bnx2x_get_leader_lock_resource(bp));
 }

-#ifdef BCM_CNIC
 static void bnx2x_cnic_cfc_comp(struct bnx2x *bp, int cid, u8 err);
-#endif

 void bnx2x_sp_event(struct bnx2x_fastpath *fp, union eth_rx_cqe *rr_cqe)
 {
@@ -1707,7 +1704,7 @@ irqreturn_t bnx2x_interrupt(int irq, void *dev_instance)
 	for_each_eth_queue(bp, i) {
 		struct bnx2x_fastpath *fp = &bp->fp[i];

-		mask = 0x2 << (fp->index + CNIC_PRESENT);
+		mask = 0x2 << (fp->index + CNIC_ENABLED(bp));
 		if (status & mask) {
 			/* Handle Rx or Tx according to SB id */
 			prefetch(fp->rx_cons_sb);
@@ -1719,22 +1716,23 @@ irqreturn_t bnx2x_interrupt(int irq, void *dev_instance)
 		}
 	}

-#ifdef BCM_CNIC
-	mask = 0x2;
-	if (status & (mask | 0x1)) {
-		struct cnic_ops *c_ops = NULL;
+	if (CNIC_ENABLED(bp)) {
+		mask = 0x2;
+		if (status & (mask | 0x1)) {
+			struct cnic_ops *c_ops = NULL;

-		if (likely(bp->state == BNX2X_STATE_OPEN)) {
-			rcu_read_lock();
-			c_ops = rcu_dereference(bp->cnic_ops);
-			if (c_ops)
-				c_ops->cnic_handler(bp->cnic_data, NULL);
-			rcu_read_unlock();
-		}
+			if (likely(bp->state == BNX2X_STATE_OPEN)) {
+				rcu_read_lock();
+				c_ops = rcu_dereference(bp->cnic_ops);
+				if (c_ops)
+					c_ops->cnic_handler(bp->cnic_data,
+							    NULL);
+				rcu_read_unlock();
+			}

-		status &= ~mask;
+			status &= ~mask;
+		}
 	}
-#endif

 	if (unlikely(status & 0x1)) {
 		queue_delayed_work(bnx2x_wq, &bp->sp_task, 0);
@@ -3057,11 +3055,13 @@ static void bnx2x_drv_info_ether_stat(struct bnx2x *bp)

 static void bnx2x_drv_info_fcoe_stat(struct bnx2x *bp)
 {
-#ifdef BCM_CNIC
 	struct bnx2x_dcbx_app_params *app = &bp->dcbx_port_params.app;
 	struct fcoe_stats_info *fcoe_stat =
 		&bp->slowpath->drv_info_to_mcp.fcoe_stat;

+	if (!CNIC_ENABLED(bp))
+		return;
+
 	memcpy(fcoe_stat->mac_local + MAC_LEADING_ZERO_CNT,
 	       bp->fip_mac, ETH_ALEN);

@@ -3144,16 +3144,17 @@ static void bnx2x_drv_info_fcoe_stat(struct bnx2x *bp)

 	/* ask L5 driver to add data to the struct */
 	bnx2x_cnic_notify(bp, CNIC_CTL_FCOE_STATS_GET_CMD);
-#endif
 }

 static void bnx2x_drv_info_iscsi_stat(struct bnx2x *bp)
 {
-#ifdef BCM_CNIC
 	struct bnx2x_dcbx_app_params *app = &bp->dcbx_port_params.app;
 	struct iscsi_stats_info *iscsi_stat =
 		&bp->slowpath->drv_info_to_mcp.iscsi_stat;

+	if (!CNIC_ENABLED(bp))
+		return;
+
 	memcpy(iscsi_stat->mac_local + MAC_LEADING_ZERO_CNT,
 	       bp->cnic_eth_dev.iscsi_mac, ETH_ALEN);

@@ -3162,7 +3163,6 @@ static void bnx2x_drv_info_iscsi_stat(struct bnx2x *bp)

 	/* ask L5 driver to add data to the struct */
 	bnx2x_cnic_notify(bp, CNIC_CTL_ISCSI_STATS_GET_CMD);
-#endif
 }

 /* called due to MCP event (on pmf):
@@ -4568,7 +4568,6 @@ static void bnx2x_update_eq_prod(struct bnx2x *bp, u16 prod)
 	mmiowb(); /* keep prod updates ordered */
 }

-#ifdef BCM_CNIC
 static int  bnx2x_cnic_handle_cfc_del(struct bnx2x *bp, u32 cid,
 				      union event_ring_elem *elem)
 {
@@ -4590,7 +4589,6 @@ static int  bnx2x_cnic_handle_cfc_del(struct bnx2x *bp, u32 cid,
 	bnx2x_cnic_cfc_comp(bp, cid, err);
 	return 0;
 }
-#endif

 static void bnx2x_handle_mcast_eqe(struct bnx2x *bp)
 {
@@ -4631,11 +4629,9 @@ static void bnx2x_handle_classification_eqe(struct bnx2x *bp,
 	switch (elem->message.data.eth_event.echo >> BNX2X_SWCID_SHIFT) {
 	case BNX2X_FILTER_MAC_PENDING:
 		DP(BNX2X_MSG_SP, "Got SETUP_MAC completions\n");
-#ifdef BCM_CNIC
-		if (cid == BNX2X_ISCSI_ETH_CID(bp))
+		if (CNIC_ENABLED(bp) && (cid == BNX2X_ISCSI_ETH_CID(bp)))
 			vlan_mac_obj = &bp->iscsi_l2_mac_obj;
 		else
-#endif
 			vlan_mac_obj = &bp->sp_objs[cid].mac_obj;

 		break;
@@ -4661,9 +4657,7 @@ static void bnx2x_handle_classification_eqe(struct bnx2x *bp,

 }

-#ifdef BCM_CNIC
 static void bnx2x_set_iscsi_eth_rx_mode(struct bnx2x *bp, bool start);
-#endif

 static void bnx2x_handle_rx_mode_eqe(struct bnx2x *bp)
 {
@@ -4674,14 +4668,12 @@ static void bnx2x_handle_rx_mode_eqe(struct bnx2x *bp)
 	/* Send rx_mode command again if was requested */
 	if (test_and_clear_bit(BNX2X_FILTER_RX_MODE_SCHED, &bp->sp_state))
 		bnx2x_set_storm_rx_mode(bp);
-#ifdef BCM_CNIC
 	else if (test_and_clear_bit(BNX2X_FILTER_ISCSI_ETH_START_SCHED,
 				    &bp->sp_state))
 		bnx2x_set_iscsi_eth_rx_mode(bp, true);
 	else if (test_and_clear_bit(BNX2X_FILTER_ISCSI_ETH_STOP_SCHED,
 				    &bp->sp_state))
 		bnx2x_set_iscsi_eth_rx_mode(bp, false);
-#endif

 	netif_addr_unlock_bh(bp->dev);
 }
@@ -4743,7 +4735,6 @@ static void bnx2x_after_function_update(struct bnx2x *bp)
 				  q);
 	}

-#ifdef BCM_CNIC
 	if (!NO_FCOE(bp)) {
 		fp = &bp->fp[FCOE_IDX(bp)];
 		queue_params.q_obj = &bnx2x_sp_obj(bp, fp).q_obj;
@@ -4766,22 +4757,16 @@ static void bnx2x_after_function_update(struct bnx2x *bp)
 		bnx2x_link_report(bp);
 		bnx2x_fw_command(bp, DRV_MSG_CODE_AFEX_VIFSET_ACK, 0);
 	}
-#else
-	/* If no FCoE ring - ACK MCP now */
-	bnx2x_link_report(bp);
-	bnx2x_fw_command(bp, DRV_MSG_CODE_AFEX_VIFSET_ACK, 0);
-#endif /* BCM_CNIC */
 }

 static struct bnx2x_queue_sp_obj *bnx2x_cid_to_q_obj(
 	struct bnx2x *bp, u32 cid)
 {
 	DP(BNX2X_MSG_SP, "retrieving fp from cid %d\n", cid);
-#ifdef BCM_CNIC
-	if (cid == BNX2X_FCOE_ETH_CID(bp))
+
+	if (CNIC_ENABLED(bp) && (cid == BNX2X_FCOE_ETH_CID(bp)))
 		return &bnx2x_fcoe_sp_obj(bp, q_obj);
 	else
-#endif
 		return &bp->sp_objs[CID_TO_FP(cid, bp)].q_obj;
 }

@@ -4843,10 +4828,11 @@ static void bnx2x_eq_int(struct bnx2x *bp)
 			 */
 			DP(BNX2X_MSG_SP,
 			   "got delete ramrod for MULTI[%d]\n", cid);
-#ifdef BCM_CNIC
-			if (!bnx2x_cnic_handle_cfc_del(bp, cid, elem))
+
+			if (CNIC_ENABLED(bp) &&
+			    !bnx2x_cnic_handle_cfc_del(bp, cid, elem))
 				goto next_spqe;
-#endif
+
 			q_obj = bnx2x_cid_to_q_obj(bp, cid);

 			if (q_obj->complete_cmd(bp, q_obj, BNX2X_Q_CMD_CFC_DEL))
@@ -4995,11 +4981,10 @@ static void bnx2x_sp_task(struct work_struct *work)

 	/* SP events: STAT_QUERY and others */
 	if (status & BNX2X_DEF_SB_IDX) {
-#ifdef BCM_CNIC
 		struct bnx2x_fastpath *fp = bnx2x_fcoe_fp(bp);

-		if ((!NO_FCOE(bp)) &&
-			(bnx2x_has_rx_work(fp) || bnx2x_has_tx_work(fp))) {
+		if (!NO_FCOE(bp) &&
+		    (bnx2x_has_rx_work(fp) || bnx2x_has_tx_work(fp))) {
 			/*
 			 * Prevent local bottom-halves from running as
 			 * we are going to change the local NAPI list.
@@ -5008,7 +4993,7 @@ static void bnx2x_sp_task(struct work_struct *work)
 			napi_schedule(&bnx2x_fcoe(bp, napi));
 			local_bh_enable();
 		}
-#endif
+
 		/* Handle EQ completions */
 		bnx2x_eq_int(bp);

@@ -5046,8 +5031,7 @@ irqreturn_t bnx2x_msix_sp_int(int irq, void *dev_instance)
 		return IRQ_HANDLED;
 #endif

-#ifdef BCM_CNIC
-	{
+	if (CNIC_ENABLED(bp)) {
 		struct cnic_ops *c_ops;

 		rcu_read_lock();
@@ -5056,7 +5040,6 @@ irqreturn_t bnx2x_msix_sp_int(int irq, void *dev_instance)
 			c_ops->cnic_handler(bp->cnic_data, NULL);
 		rcu_read_unlock();
 	}
-#endif
 	queue_delayed_work(bnx2x_wq, &bp->sp_task, 0);

 	return IRQ_HANDLED;
@@ -5494,12 +5477,10 @@ void bnx2x_set_storm_rx_mode(struct bnx2x *bp)
 	unsigned long rx_mode_flags = 0, ramrod_flags = 0;
 	unsigned long rx_accept_flags = 0, tx_accept_flags = 0;

-#ifdef BCM_CNIC
 	if (!NO_FCOE(bp))

 		/* Configure rx_mode of FCoE Queue */
 		__set_bit(BNX2X_RX_MODE_FCOE_ETH, &rx_mode_flags);
-#endif

 	switch (bp->rx_mode) {
 	case BNX2X_RX_MODE_NONE:
@@ -5620,12 +5601,12 @@ static void bnx2x_init_internal(struct bnx2x *bp, u32 load_code)

 static inline u8 bnx2x_fp_igu_sb_id(struct bnx2x_fastpath *fp)
 {
-	return fp->bp->igu_base_sb + fp->index + CNIC_PRESENT;
+	return fp->bp->igu_base_sb + fp->index + CNIC_ENABLED(fp->bp);
 }

 static inline u8 bnx2x_fp_fw_sb_id(struct bnx2x_fastpath *fp)
 {
-	return fp->bp->base_fw_ndsb + fp->index + CNIC_PRESENT;
+	return fp->bp->base_fw_ndsb + fp->index + CNIC_ENABLED(fp->bp);
 }

 static u8 bnx2x_fp_cl_id(struct bnx2x_fastpath *fp)
@@ -5732,15 +5713,16 @@ void bnx2x_nic_init(struct bnx2x *bp, u32 load_code)

 	for_each_eth_queue(bp, i)
 		bnx2x_init_eth_fp(bp, i);
-#ifdef BCM_CNIC
-	if (!NO_FCOE(bp))
-		bnx2x_init_fcoe_fp(bp);

-	bnx2x_init_sb(bp, bp->cnic_sb_mapping,
-		      BNX2X_VF_ID_INVALID, false,
-		      bnx2x_cnic_fw_sb_id(bp), bnx2x_cnic_igu_sb_id(bp));
+	if (CNIC_ENABLED(bp)) {
+		if (!NO_FCOE(bp))
+			bnx2x_init_fcoe_fp(bp);

-#endif
+		bnx2x_init_sb(bp, bp->cnic_sb_mapping,
+			      BNX2X_VF_ID_INVALID, false,
+			      bnx2x_cnic_fw_sb_id(bp),
+			      bnx2x_cnic_igu_sb_id(bp));
+	}

 	/* Initialize MOD_ABS interrupts */
 	bnx2x_init_mod_abs_int(bp, &bp->link_vars, bp->common.chip_id,
@@ -6027,10 +6009,10 @@ static int bnx2x_int_mem_test(struct bnx2x *bp)
 	msleep(50);
 	bnx2x_init_block(bp, BLOCK_BRB1, PHASE_COMMON);
 	bnx2x_init_block(bp, BLOCK_PRS, PHASE_COMMON);
-#ifndef BCM_CNIC
-	/* set NIC mode */
-	REG_WR(bp, PRS_REG_NIC_MODE, 1);
-#endif
+	if (!CNIC_ENABLED(bp)) {
+		/* set NIC mode */
+		REG_WR(bp, PRS_REG_NIC_MODE, 1);
+	}

 	/* Enable inputs of parser neighbor blocks */
 	REG_WR(bp, TSDM_REG_ENABLE_IN1, 0x7fffffff);
@@ -6519,9 +6501,8 @@ static int bnx2x_init_hw_common(struct bnx2x *bp)
 	REG_WR(bp, QM_REG_SOFT_RESET, 1);
 	REG_WR(bp, QM_REG_SOFT_RESET, 0);

-#ifdef BCM_CNIC
-	bnx2x_init_block(bp, BLOCK_TM, PHASE_COMMON);
-#endif
+	if (CNIC_ENABLED(bp))
+		bnx2x_init_block(bp, BLOCK_TM, PHASE_COMMON);

 	bnx2x_init_block(bp, BLOCK_DORQ, PHASE_COMMON);
 	REG_WR(bp, DORQ_REG_DPM_CID_OFST, BNX2X_DB_SHIFT);
@@ -6608,18 +6589,18 @@ static int bnx2x_init_hw_common(struct bnx2x *bp)

 	bnx2x_init_block(bp, BLOCK_SRC, PHASE_COMMON);

-#ifdef BCM_CNIC
-	REG_WR(bp, SRC_REG_KEYSEARCH_0, 0x63285672);
-	REG_WR(bp, SRC_REG_KEYSEARCH_1, 0x24b8f2cc);
-	REG_WR(bp, SRC_REG_KEYSEARCH_2, 0x223aef9b);
-	REG_WR(bp, SRC_REG_KEYSEARCH_3, 0x26001e3a);
-	REG_WR(bp, SRC_REG_KEYSEARCH_4, 0x7ae91116);
-	REG_WR(bp, SRC_REG_KEYSEARCH_5, 0x5ce5230b);
-	REG_WR(bp, SRC_REG_KEYSEARCH_6, 0x298d8adf);
-	REG_WR(bp, SRC_REG_KEYSEARCH_7, 0x6eb0ff09);
-	REG_WR(bp, SRC_REG_KEYSEARCH_8, 0x1830f82f);
-	REG_WR(bp, SRC_REG_KEYSEARCH_9, 0x01e46be7);
-#endif
+	if (CNIC_ENABLED(bp)) {
+		REG_WR(bp, SRC_REG_KEYSEARCH_0, 0x63285672);
+		REG_WR(bp, SRC_REG_KEYSEARCH_1, 0x24b8f2cc);
+		REG_WR(bp, SRC_REG_KEYSEARCH_2, 0x223aef9b);
+		REG_WR(bp, SRC_REG_KEYSEARCH_3, 0x26001e3a);
+		REG_WR(bp, SRC_REG_KEYSEARCH_4, 0x7ae91116);
+		REG_WR(bp, SRC_REG_KEYSEARCH_5, 0x5ce5230b);
+		REG_WR(bp, SRC_REG_KEYSEARCH_6, 0x298d8adf);
+		REG_WR(bp, SRC_REG_KEYSEARCH_7, 0x6eb0ff09);
+		REG_WR(bp, SRC_REG_KEYSEARCH_8, 0x1830f82f);
+		REG_WR(bp, SRC_REG_KEYSEARCH_9, 0x01e46be7);
+	}
 	REG_WR(bp, SRC_REG_SOFT_RST, 0);

 	if (sizeof(union cdu_context) != 1024)
@@ -6784,11 +6765,11 @@ static int bnx2x_init_hw_port(struct bnx2x *bp)
 	/* QM cid (connection) count */
 	bnx2x_qm_init_cid_count(bp, bp->qm_cid_count, INITOP_SET);

-#ifdef BCM_CNIC
-	bnx2x_init_block(bp, BLOCK_TM, init_phase);
-	REG_WR(bp, TM_REG_LIN0_SCAN_TIME + port*4, 20);
-	REG_WR(bp, TM_REG_LIN0_MAX_ACTIVE_CID + port*4, 31);
-#endif
+	if (CNIC_ENABLED(bp)) {
+		bnx2x_init_block(bp, BLOCK_TM, init_phase);
+		REG_WR(bp, TM_REG_LIN0_SCAN_TIME + port*4, 20);
+		REG_WR(bp, TM_REG_LIN0_MAX_ACTIVE_CID + port*4, 31);
+	}

 	bnx2x_init_block(bp, BLOCK_DORQ, init_phase);

@@ -6874,9 +6855,8 @@ static int bnx2x_init_hw_port(struct bnx2x *bp)
 		REG_WR(bp, PBF_REG_INIT_P0 + port*4, 0);
 	}

-#ifdef BCM_CNIC
-	bnx2x_init_block(bp, BLOCK_SRC, init_phase);
-#endif
+	if (CNIC_ENABLED(bp))
+		bnx2x_init_block(bp, BLOCK_SRC, init_phase);
 	bnx2x_init_block(bp, BLOCK_CDU, init_phase);
 	bnx2x_init_block(bp, BLOCK_CFC, init_phase);

@@ -7079,18 +7059,15 @@ static int bnx2x_init_hw_func(struct bnx2x *bp)
 	}
 	bnx2x_ilt_init_op(bp, INITOP_SET);

-#ifdef BCM_CNIC
-	bnx2x_src_init_t2(bp, bp->t2, bp->t2_mapping, SRC_CONN_NUM);
-
-	/* T1 hash bits value determines the T1 number of entries */
-	REG_WR(bp, SRC_REG_NUMBER_HASH_BITS0 + port*4, SRC_HASH_BITS);
-#endif
-
-#ifndef BCM_CNIC
-	/* set NIC mode */
-	REG_WR(bp, PRS_REG_NIC_MODE, 1);
-#endif  /* BCM_CNIC */
+	if (CNIC_ENABLED(bp)) {
+		bnx2x_src_init_t2(bp, bp->t2, bp->t2_mapping, SRC_CONN_NUM);

+		/* T1 hash bits value determines the T1 number of entries */
+		REG_WR(bp, SRC_REG_NUMBER_HASH_BITS0 + port*4, SRC_HASH_BITS);
+	} else {
+		/* set NIC mode */
+		REG_WR(bp, PRS_REG_NIC_MODE, 1);
+	}
 	if (!CHIP_IS_E1x(bp)) {
 		u32 pf_conf = IGU_PF_CONF_FUNC_EN;

@@ -7364,16 +7341,16 @@ void bnx2x_free_mem(struct bnx2x *bp)

 	BNX2X_FREE(bp->ilt->lines);

-#ifdef BCM_CNIC
-	if (!CHIP_IS_E1x(bp))
-		BNX2X_PCI_FREE(bp->cnic_sb.e2_sb, bp->cnic_sb_mapping,
-			       sizeof(struct host_hc_status_block_e2));
-	else
-		BNX2X_PCI_FREE(bp->cnic_sb.e1x_sb, bp->cnic_sb_mapping,
-			       sizeof(struct host_hc_status_block_e1x));
+	if (CNIC_ENABLED(bp)) {
+		if (!CHIP_IS_E1x(bp))
+			BNX2X_PCI_FREE(bp->cnic_sb.e2_sb, bp->cnic_sb_mapping,
+				       sizeof(struct host_hc_status_block_e2));
+		else
+			BNX2X_PCI_FREE(bp->cnic_sb.e1x_sb, bp->cnic_sb_mapping,
+				       sizeof(struct host_hc_status_block_e1x));

-	BNX2X_PCI_FREE(bp->t2, bp->t2_mapping, SRC_T2_SZ);
-#endif
+		BNX2X_PCI_FREE(bp->t2, bp->t2_mapping, SRC_T2_SZ);
+	}

 	BNX2X_PCI_FREE(bp->spq, bp->spq_mapping, BCM_PAGE_SIZE);

@@ -7447,19 +7424,20 @@ int bnx2x_alloc_mem(struct bnx2x *bp)
 {
 	int i, allocated, context_size;

-#ifdef BCM_CNIC
-	if (!CHIP_IS_E1x(bp))
-		/* size = the status block + ramrod buffers */
-		BNX2X_PCI_ALLOC(bp->cnic_sb.e2_sb, &bp->cnic_sb_mapping,
-				sizeof(struct host_hc_status_block_e2));
-	else
-		BNX2X_PCI_ALLOC(bp->cnic_sb.e1x_sb, &bp->cnic_sb_mapping,
-				sizeof(struct host_hc_status_block_e1x));
-
-	/* allocate searcher T2 table */
-	BNX2X_PCI_ALLOC(bp->t2, &bp->t2_mapping, SRC_T2_SZ);
-#endif
+	if (CNIC_ENABLED(bp)) {
+		if (!CHIP_IS_E1x(bp))
+			/* size = the status block + ramrod buffers */
+			BNX2X_PCI_ALLOC(bp->cnic_sb.e2_sb, &bp->cnic_sb_mapping,
+					sizeof(struct host_hc_status_block_e2));
+		else
+			BNX2X_PCI_ALLOC(bp->cnic_sb.e1x_sb,
+					&bp->cnic_sb_mapping,
+					sizeof(struct
+					       host_hc_status_block_e1x));

+		/* allocate searcher T2 table */
+		BNX2X_PCI_ALLOC(bp->t2, &bp->t2_mapping, SRC_T2_SZ);
+	}

 	BNX2X_PCI_ALLOC(bp->def_status_blk, &bp->def_status_blk_mapping,
 			sizeof(struct host_sp_status_block));
@@ -7467,10 +7445,11 @@ int bnx2x_alloc_mem(struct bnx2x *bp)
 	BNX2X_PCI_ALLOC(bp->slowpath, &bp->slowpath_mapping,
 			sizeof(struct bnx2x_slowpath));

-#ifdef BCM_CNIC
-	/* write address to which L5 should insert its values */
-	bp->cnic_eth_dev.addr_drv_info_to_mcp = &bp->slowpath->drv_info_to_mcp;
-#endif
+	if (CNIC_ENABLED(bp))
+		/* write address to which L5 should insert its values */
+		bp->cnic_eth_dev.addr_drv_info_to_mcp =
+			&bp->slowpath->drv_info_to_mcp;
+

 	/* Allocated memory for FW statistics  */
 	if (bnx2x_alloc_fw_stats_mem(bp))
@@ -7587,14 +7566,12 @@ int bnx2x_set_eth_mac(struct bnx2x *bp, bool set)
 {
 	unsigned long ramrod_flags = 0;

-#ifdef BCM_CNIC
-	if (is_zero_ether_addr(bp->dev->dev_addr) &&
+	if (CNIC_ENABLED(bp) && is_zero_ether_addr(bp->dev->dev_addr) &&
 	    (IS_MF_STORAGE_SD(bp) || IS_MF_FCOE_AFEX(bp))) {
 		DP(NETIF_MSG_IFUP | NETIF_MSG_IFDOWN,
 		   "Ignoring Zero MAC for STORAGE SD mode\n");
 		return 0;
 	}
-#endif

 	DP(NETIF_MSG_IFUP, "Adding Eth MAC\n");

@@ -7623,7 +7600,8 @@ void bnx2x_set_int_mode(struct bnx2x *bp)
 		bnx2x_enable_msi(bp);
 		/* falling through... */
 	case INT_MODE_INTx:
-		bp->num_queues = 1 + NON_ETH_CONTEXT_USE;
+		bp->num_ethernet_queues = 1;
+		bp->num_queues = bp->num_ethernet_queues + bp->num_cnic_queues;
 		BNX2X_DEV_INFO("set number of queues to 1\n");
 		break;
 	default:
@@ -7635,9 +7613,12 @@ void bnx2x_set_int_mode(struct bnx2x *bp)
 		    bp->flags & USING_SINGLE_MSIX_FLAG) {
 			/* failed to enable multiple MSI-X */
 			BNX2X_DEV_INFO("Failed to enable multiple MSI-X (%d), set number of queues to %d\n",
-				       bp->num_queues, 1 + NON_ETH_CONTEXT_USE);
+				       bp->num_queues,
+				       1 + bp->num_cnic_queues);

-			bp->num_queues = 1 + NON_ETH_CONTEXT_USE;
+			bp->num_ethernet_queues = 1;
+			bp->num_queues = bp->num_ethernet_queues +
+					 bp->num_cnic_queues;

 			/* Try to enable MSI */
 			if (!(bp->flags & USING_SINGLE_MSIX_FLAG) &&
@@ -7670,9 +7651,9 @@ void bnx2x_ilt_set_info(struct bnx2x *bp)
 	ilt_client->flags = ILT_CLIENT_SKIP_MEM;
 	ilt_client->start = line;
 	line += bnx2x_cid_ilt_lines(bp);
-#ifdef BCM_CNIC
-	line += CNIC_ILT_LINES;
-#endif
+
+	if (CNIC_ENABLED(bp))
+		line += CNIC_ILT_LINES;
 	ilt_client->end = line - 1;

 	DP(NETIF_MSG_IFUP, "ilt client[CDU]: start %d, end %d, psz 0x%x, flags 0x%x, hw psz %d\n",
@@ -7707,47 +7688,47 @@ void bnx2x_ilt_set_info(struct bnx2x *bp)
 	}
 	/* SRC */
 	ilt_client = &ilt->clients[ILT_CLIENT_SRC];
-#ifdef BCM_CNIC
-	ilt_client->client_num = ILT_CLIENT_SRC;
-	ilt_client->page_size = SRC_ILT_PAGE_SZ;
-	ilt_client->flags = 0;
-	ilt_client->start = line;
-	line += SRC_ILT_LINES;
-	ilt_client->end = line - 1;
-
-	DP(NETIF_MSG_IFUP,
-	   "ilt client[SRC]: start %d, end %d, psz 0x%x, flags 0x%x, hw psz %d\n",
-	   ilt_client->start,
-	   ilt_client->end,
-	   ilt_client->page_size,
-	   ilt_client->flags,
-	   ilog2(ilt_client->page_size >> 12));
+	if (CNIC_ENABLED(bp)) {
+		ilt_client->client_num = ILT_CLIENT_SRC;
+		ilt_client->page_size = SRC_ILT_PAGE_SZ;
+		ilt_client->flags = 0;
+		ilt_client->start = line;
+		line += SRC_ILT_LINES;
+		ilt_client->end = line - 1;

-#else
-	ilt_client->flags = (ILT_CLIENT_SKIP_INIT | ILT_CLIENT_SKIP_MEM);
-#endif
+		DP(NETIF_MSG_IFUP,
+		   "ilt client[SRC]: start %d, end %d, psz 0x%x, flags 0x%x, hw psz %d\n",
+		   ilt_client->start,
+		   ilt_client->end,
+		   ilt_client->page_size,
+		   ilt_client->flags,
+		   ilog2(ilt_client->page_size >> 12));
+	} else
+		ilt_client->flags = (ILT_CLIENT_SKIP_INIT |
+				     ILT_CLIENT_SKIP_MEM);

 	/* TM */
 	ilt_client = &ilt->clients[ILT_CLIENT_TM];
-#ifdef BCM_CNIC
-	ilt_client->client_num = ILT_CLIENT_TM;
-	ilt_client->page_size = TM_ILT_PAGE_SZ;
-	ilt_client->flags = 0;
-	ilt_client->start = line;
-	line += TM_ILT_LINES;
-	ilt_client->end = line - 1;
+	if (CNIC_ENABLED(bp)) {
+		ilt_client->client_num = ILT_CLIENT_TM;
+		ilt_client->page_size = TM_ILT_PAGE_SZ;
+		ilt_client->flags = 0;
+		ilt_client->start = line;
+		line += TM_ILT_LINES;
+		ilt_client->end = line - 1;

-	DP(NETIF_MSG_IFUP,
-	   "ilt client[TM]: start %d, end %d, psz 0x%x, flags 0x%x, hw psz %d\n",
-	   ilt_client->start,
-	   ilt_client->end,
-	   ilt_client->page_size,
-	   ilt_client->flags,
-	   ilog2(ilt_client->page_size >> 12));
+		DP(NETIF_MSG_IFUP,
+		   "ilt client[TM]: start %d, end %d, psz 0x%x, flags 0x%x, hw psz %d\n",
+		   ilt_client->start,
+		   ilt_client->end,
+		   ilt_client->page_size,
+		   ilt_client->flags,
+		   ilog2(ilt_client->page_size >> 12));
+
+	} else
+		ilt_client->flags = (ILT_CLIENT_SKIP_INIT |
+				     ILT_CLIENT_SKIP_MEM);

-#else
-	ilt_client->flags = (ILT_CLIENT_SKIP_INIT | ILT_CLIENT_SKIP_MEM);
-#endif
 	BUG_ON(line > ILT_MAX_LINES);
 }

@@ -8028,12 +8009,12 @@ static void bnx2x_reset_func(struct bnx2x *bp)
 			   SB_DISABLED);
 	}

-#ifdef BCM_CNIC
-	/* CNIC SB */
-	REG_WR8(bp, BAR_CSTRORM_INTMEM +
-		CSTORM_STATUS_BLOCK_DATA_STATE_OFFSET(bnx2x_cnic_fw_sb_id(bp)),
-		SB_DISABLED);
-#endif
+	if (CNIC_ENABLED(bp)) {
+		/* CNIC SB */
+		REG_WR8(bp, BAR_CSTRORM_INTMEM +
+			CSTORM_STATUS_BLOCK_DATA_STATE_OFFSET
+			(bnx2x_cnic_fw_sb_id(bp)), SB_DISABLED);
+	}
 	/* SP SB */
 	REG_WR8(bp, BAR_CSTRORM_INTMEM +
 		   CSTORM_SP_STATUS_BLOCK_DATA_STATE_OFFSET(func),
@@ -8052,19 +8033,19 @@ static void bnx2x_reset_func(struct bnx2x *bp)
 		REG_WR(bp, IGU_REG_TRAILING_EDGE_LATCH, 0);
 	}

-#ifdef BCM_CNIC
-	/* Disable Timer scan */
-	REG_WR(bp, TM_REG_EN_LINEAR0_TIMER + port*4, 0);
-	/*
-	 * Wait for at least 10ms and up to 2 second for the timers scan to
-	 * complete
-	 */
-	for (i = 0; i < 200; i++) {
-		msleep(10);
-		if (!REG_RD(bp, TM_REG_LIN0_SCAN_ON + port*4))
-			break;
+	if (CNIC_ENABLED(bp)) {
+		/* Disable Timer scan */
+		REG_WR(bp, TM_REG_EN_LINEAR0_TIMER + port*4, 0);
+		/*
+		 * Wait for at least 10ms and up to 2 second for the timers
+		 * scan to complete
+		 */
+		for (i = 0; i < 200; i++) {
+			msleep(10);
+			if (!REG_RD(bp, TM_REG_LIN0_SCAN_ON + port*4))
+				break;
+		}
 	}
-#endif
 	/* Clear ILT */
 	bnx2x_clear_func_ilt(bp, func);

@@ -10211,12 +10192,15 @@ static void __devinit bnx2x_get_port_hwinfo(struct bnx2x *bp)
 void bnx2x_get_iscsi_info(struct bnx2x *bp)
 {
 	u32 no_flags = NO_ISCSI_FLAG;
-#ifdef BCM_CNIC
 	int port = BP_PORT(bp);
-
 	u32 max_iscsi_conn = FW_ENCODE_32BIT_PATTERN ^ SHMEM_RD(bp,
 				drv_lic_key[port].max_iscsi_conn);

+	if (!CNIC_ENABLED(bp)) {
+		bp->flags |= no_flags;
+		return;
+	}
+
 	/* Get the number of maximum allowed iSCSI connections */
 	bp->cnic_eth_dev.max_iscsi_conn =
 		(max_iscsi_conn & BNX2X_MAX_ISCSI_INIT_CONN_MASK) >>
@@ -10231,12 +10215,8 @@ void bnx2x_get_iscsi_info(struct bnx2x *bp)
 	 */
 	if (!bp->cnic_eth_dev.max_iscsi_conn)
 		bp->flags |= no_flags;
-#else
-	bp->flags |= no_flags;
-#endif
 }

-#ifdef BCM_CNIC
 static void __devinit bnx2x_get_ext_wwn_info(struct bnx2x *bp, int func)
 {
 	/* Port info */
@@ -10251,16 +10231,18 @@ static void __devinit bnx2x_get_ext_wwn_info(struct bnx2x *bp, int func)
 	bp->cnic_eth_dev.fcoe_wwn_node_name_lo =
 		MF_CFG_RD(bp, func_ext_config[func].fcoe_wwn_node_name_lower);
 }
-#endif
 static void __devinit bnx2x_get_fcoe_info(struct bnx2x *bp)
 {
-#ifdef BCM_CNIC
 	int port = BP_PORT(bp);
 	int func = BP_ABS_FUNC(bp);
-
 	u32 max_fcoe_conn = FW_ENCODE_32BIT_PATTERN ^ SHMEM_RD(bp,
 				drv_lic_key[port].max_fcoe_conn);

+	if (!CNIC_ENABLED(bp)) {
+		bp->flags |= NO_FCOE_FLAG;
+		return;
+	}
+
 	/* Get the number of maximum allowed FCoE connections */
 	bp->cnic_eth_dev.max_fcoe_conn =
 		(max_fcoe_conn & BNX2X_MAX_FCOE_INIT_CONN_MASK) >>
@@ -10270,37 +10252,33 @@ static void __devinit bnx2x_get_fcoe_info(struct bnx2x *bp)
 	if (!IS_MF(bp)) {
 		/* Port info */
 		bp->cnic_eth_dev.fcoe_wwn_port_name_hi =
-			SHMEM_RD(bp,
-				dev_info.port_hw_config[port].
+			SHMEM_RD(bp, dev_info.port_hw_config[port].
 				 fcoe_wwn_port_name_upper);
 		bp->cnic_eth_dev.fcoe_wwn_port_name_lo =
-			SHMEM_RD(bp,
-				dev_info.port_hw_config[port].
+			SHMEM_RD(bp, dev_info.port_hw_config[port].
 				 fcoe_wwn_port_name_lower);

 		/* Node info */
 		bp->cnic_eth_dev.fcoe_wwn_node_name_hi =
-			SHMEM_RD(bp,
-				dev_info.port_hw_config[port].
+			SHMEM_RD(bp, dev_info.port_hw_config[port].
 				 fcoe_wwn_node_name_upper);
 		bp->cnic_eth_dev.fcoe_wwn_node_name_lo =
-			SHMEM_RD(bp,
-				dev_info.port_hw_config[port].
+			SHMEM_RD(bp, dev_info.port_hw_config[port].
 				 fcoe_wwn_node_name_lower);
 	} else if (!IS_MF_SD(bp)) {
-		u32 cfg = MF_CFG_RD(bp, func_ext_config[func].func_cfg);
-
 		/*
-		 * Read the WWN info only if the FCoE feature is enabled for
-		 * this function.
+		 * Read the WWN info only if the FCoE feature is
+		 * enabled for this function.
 		 */
-		if (cfg & MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD)
+		if (BNX2X_MF_EXT_PROTOCOL_FCOE(bp))
 			bnx2x_get_ext_wwn_info(bp, func);

-	} else if (IS_MF_FCOE_SD(bp))
+	} else if (IS_MF_FCOE_SD(bp)) {
 		bnx2x_get_ext_wwn_info(bp, func);
+	}

-	BNX2X_DEV_INFO("max_fcoe_conn 0x%x\n", bp->cnic_eth_dev.max_fcoe_conn);
+	BNX2X_DEV_INFO("max_fcoe_conn 0x%x\n",
+		       bp->cnic_eth_dev.max_fcoe_conn);

 	/*
 	 * If maximum allowed number of connections is zero -
@@ -10308,9 +10286,6 @@ static void __devinit bnx2x_get_fcoe_info(struct bnx2x *bp)
 	 */
 	if (!bp->cnic_eth_dev.max_fcoe_conn)
 		bp->flags |= NO_FCOE_FLAG;
-#else
-	bp->flags |= NO_FCOE_FLAG;
-#endif
 }

 static void __devinit bnx2x_get_cnic_info(struct bnx2x *bp)
@@ -10324,36 +10299,19 @@ static void __devinit bnx2x_get_cnic_info(struct bnx2x *bp)
 	bnx2x_get_fcoe_info(bp);
 }

-static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp)
+static void __devinit bnx2x_get_cnic_mac_hwinfo(struct bnx2x *bp)
 {
 	u32 val, val2;
 	int func = BP_ABS_FUNC(bp);
 	int port = BP_PORT(bp);
-#ifdef BCM_CNIC
 	u8 *iscsi_mac = bp->cnic_eth_dev.iscsi_mac;
 	u8 *fip_mac = bp->fip_mac;
-#endif
-
-	/* Zero primary MAC configuration */
-	memset(bp->dev->dev_addr, 0, ETH_ALEN);

-	if (BP_NOMCP(bp)) {
-		BNX2X_ERROR("warning: random MAC workaround active\n");
-		eth_hw_addr_random(bp->dev);
-	} else if (IS_MF(bp)) {
-		val2 = MF_CFG_RD(bp, func_mf_config[func].mac_upper);
-		val = MF_CFG_RD(bp, func_mf_config[func].mac_lower);
-		if ((val2 != FUNC_MF_CFG_UPPERMAC_DEFAULT) &&
-		    (val != FUNC_MF_CFG_LOWERMAC_DEFAULT))
-			bnx2x_set_mac_buf(bp->dev->dev_addr, val, val2);
-
-#ifdef BCM_CNIC
-		/*
-		 * iSCSI and FCoE NPAR MACs: if there is no either iSCSI or
+	if (IS_MF(bp)) {
+		/* iSCSI and FCoE NPAR MACs: if there is no either iSCSI or
 		 * FCoE MAC then the appropriate feature should be disabled.
-		 *
-		 * In non SD mode features configuration comes from
-		 * struct func_ext_config.
+		 * In non SD mode features configuration comes from struct
+		 * func_ext_config.
 		 */
 		if (!IS_MF_SD(bp)) {
 			u32 cfg = MF_CFG_RD(bp, func_ext_config[func].func_cfg);
@@ -10365,8 +10323,9 @@ static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp)
 				bnx2x_set_mac_buf(iscsi_mac, val, val2);
 				BNX2X_DEV_INFO("Read iSCSI MAC: %pM\n",
 					       iscsi_mac);
-			} else
+			} else {
 				bp->flags |= NO_ISCSI_OOO_FLAG | NO_ISCSI_FLAG;
+			}

 			if (cfg & MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD) {
 				val2 = MF_CFG_RD(bp, func_ext_config[func].
@@ -10377,8 +10336,9 @@ static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp)
 				BNX2X_DEV_INFO("Read FCoE L2 MAC: %pM\n",
 					       fip_mac);

-			} else
+			} else {
 				bp->flags |= NO_FCOE_FLAG;
+			}

 			bp->mf_ext_config = cfg;

@@ -10408,14 +10368,7 @@ static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp)
 			/* use FIP MAC as primary MAC */
 			memcpy(bp->dev->dev_addr, fip_mac, ETH_ALEN);

-#endif
 	} else {
-		/* in SF read MACs from port configuration */
-		val2 = SHMEM_RD(bp, dev_info.port_hw_config[port].mac_upper);
-		val = SHMEM_RD(bp, dev_info.port_hw_config[port].mac_lower);
-		bnx2x_set_mac_buf(bp->dev->dev_addr, val, val2);
-
-#ifdef BCM_CNIC
 		val2 = SHMEM_RD(bp, dev_info.port_hw_config[port].
 				    iscsi_mac_upper);
 		val = SHMEM_RD(bp, dev_info.port_hw_config[port].
@@ -10427,29 +10380,54 @@ static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp)
 		val = SHMEM_RD(bp, dev_info.port_hw_config[port].
 				   fcoe_fip_mac_lower);
 		bnx2x_set_mac_buf(fip_mac, val, val2);
-#endif
 	}

-	memcpy(bp->link_params.mac_addr, bp->dev->dev_addr, ETH_ALEN);
-	memcpy(bp->dev->perm_addr, bp->dev->dev_addr, ETH_ALEN);
-
-#ifdef BCM_CNIC
-	/* Disable iSCSI if MAC configuration is
-	 * invalid.
-	 */
+	/* Disable iSCSI OOO if MAC configuration is invalid. */
 	if (!is_valid_ether_addr(iscsi_mac)) {
 		bp->flags |= NO_ISCSI_FLAG;
 		memset(iscsi_mac, 0, ETH_ALEN);
 	}

-	/* Disable FCoE if MAC configuration is
-	 * invalid.
-	 */
+	/* Disable FCoE if MAC configuration is invalid. */
 	if (!is_valid_ether_addr(fip_mac)) {
 		bp->flags |= NO_FCOE_FLAG;
 		memset(bp->fip_mac, 0, ETH_ALEN);
 	}
-#endif
+}
+
+static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp)
+{
+	u32 val, val2;
+	int func = BP_ABS_FUNC(bp);
+	int port = BP_PORT(bp);
+
+	/* Zero primary MAC configuration */
+	memset(bp->dev->dev_addr, 0, ETH_ALEN);
+
+	if (BP_NOMCP(bp)) {
+		BNX2X_ERROR("warning: random MAC workaround active\n");
+		eth_hw_addr_random(bp->dev);
+	} else if (IS_MF(bp)) {
+		val2 = MF_CFG_RD(bp, func_mf_config[func].mac_upper);
+		val = MF_CFG_RD(bp, func_mf_config[func].mac_lower);
+		if ((val2 != FUNC_MF_CFG_UPPERMAC_DEFAULT) &&
+		    (val != FUNC_MF_CFG_LOWERMAC_DEFAULT))
+			bnx2x_set_mac_buf(bp->dev->dev_addr, val, val2);
+
+		if (CNIC_ENABLED(bp))
+			bnx2x_get_cnic_mac_hwinfo(bp);
+	} else {
+		/* in SF read MACs from port configuration */
+		val2 = SHMEM_RD(bp, dev_info.port_hw_config[port].mac_upper);
+		val = SHMEM_RD(bp, dev_info.port_hw_config[port].mac_lower);
+		bnx2x_set_mac_buf(bp->dev->dev_addr, val, val2);
+
+		if (CNIC_ENABLED(bp))
+			bnx2x_get_cnic_mac_hwinfo(bp);
+	}
+
+	memcpy(bp->link_params.mac_addr, bp->dev->dev_addr, ETH_ALEN);
+	memcpy(bp->dev->perm_addr, bp->dev->dev_addr, ETH_ALEN);

 	if (!bnx2x_is_valid_ether_addr(bp, bp->dev->dev_addr))
 		dev_err(&bp->pdev->dev,
@@ -10826,9 +10804,9 @@ static int __devinit bnx2x_init_bp(struct bnx2x *bp)
 	mutex_init(&bp->port.phy_mutex);
 	mutex_init(&bp->fw_mb_mutex);
 	spin_lock_init(&bp->stats_lock);
-#ifdef BCM_CNIC
-	mutex_init(&bp->cnic_mutex);
-#endif
+	if (CNIC_ENABLED(bp))
+		mutex_init(&bp->cnic_mutex);
+

 	INIT_DELAYED_WORK(&bp->sp_task, bnx2x_sp_task);
 	INIT_DELAYED_WORK(&bp->sp_rtnl_task, bnx2x_sp_rtnl_task);
@@ -10867,9 +10845,8 @@ static int __devinit bnx2x_init_bp(struct bnx2x *bp)

 	bp->disable_tpa = disable_tpa;

-#ifdef BCM_CNIC
-	bp->disable_tpa |= IS_MF_STORAGE_SD(bp) || IS_MF_FCOE_AFEX(bp);
-#endif
+	if (CNIC_ENABLED(bp))
+		bp->disable_tpa |= IS_MF_STORAGE_SD(bp) || IS_MF_FCOE_AFEX(bp);

 	/* Set TPA flags */
 	if (bp->disable_tpa) {
@@ -10903,12 +10880,10 @@ static int __devinit bnx2x_init_bp(struct bnx2x *bp)
 	bnx2x_dcbx_set_state(bp, true, BNX2X_DCBX_ENABLED_ON_NEG_ON);
 	bnx2x_dcbx_init_params(bp);

-#ifdef BCM_CNIC
 	if (CHIP_IS_E1x(bp))
 		bp->cnic_base_cl_id = FP_SB_MAX_E1x;
 	else
 		bp->cnic_base_cl_id = FP_SB_MAX_E2;
-#endif

 	/* multiple tx priority */
 	if (CHIP_IS_E1x(bp))
@@ -10918,6 +10893,11 @@ static int __devinit bnx2x_init_bp(struct bnx2x *bp)
 	if (CHIP_IS_E3B0(bp))
 		bp->max_cos = BNX2X_MULTI_TX_COS_E3B0;

+	if (CNIC_ENABLED(bp))
+		bp->min_msix_vec_cnt = 3;
+	else
+		bp->min_msix_vec_cnt = 2;
+
 	return rc;
 }

@@ -11147,11 +11127,9 @@ void bnx2x_set_rx_mode(struct net_device *dev)
 	}

 	bp->rx_mode = rx_mode;
-#ifdef BCM_CNIC
 	/* handle ISCSI SD mode */
-	if (IS_MF_ISCSI_SD(bp))
+	if (CNIC_ENABLED(bp) && IS_MF_ISCSI_SD(bp))
 		bp->rx_mode = BNX2X_RX_MODE_NONE;
-#endif

 	/* Schedule the rx_mode command */
 	if (test_bit(BNX2X_FILTER_RX_MODE_PENDING, &bp->sp_state)) {
@@ -11243,11 +11221,10 @@ static int bnx2x_validate_addr(struct net_device *dev)
 	return 0;
 }

-static const struct net_device_ops bnx2x_netdev_ops = {
+static struct net_device_ops bnx2x_netdev_ops = {
 	.ndo_open		= bnx2x_open,
 	.ndo_stop		= bnx2x_close,
 	.ndo_start_xmit		= bnx2x_start_xmit,
-	.ndo_select_queue	= bnx2x_select_queue,
 	.ndo_set_rx_mode	= bnx2x_set_rx_mode,
 	.ndo_set_mac_address	= bnx2x_change_mac_addr,
 	.ndo_validate_addr	= bnx2x_validate_addr,
@@ -11261,9 +11238,6 @@ static const struct net_device_ops bnx2x_netdev_ops = {
 #endif
 	.ndo_setup_tc		= bnx2x_setup_tc,

-#if defined(NETDEV_FCOE_WWNN) && defined(BCM_CNIC)
-	.ndo_fcoe_get_wwn	= bnx2x_fcoe_get_wwn,
-#endif
 };

 static int bnx2x_set_coherency_mask(struct bnx2x *bp)
@@ -11415,6 +11389,12 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev,

 	dev->watchdog_timeo = TX_TIMEOUT;

+	if (CNIC_ENABLED(bp))
+		bnx2x_netdev_ops.ndo_select_queue = bnx2x_select_queue;
+#if defined(NETDEV_FCOE_WWNN)
+	if (CNIC_ENABLED(bp))
+		bnx2x_netdev_ops.ndo_fcoe_get_wwn = bnx2x_fcoe_get_wwn;
+#endif
 	dev->netdev_ops = &bnx2x_netdev_ops;
 	bnx2x_set_ethtool_ops(dev);

@@ -11731,9 +11711,8 @@ static int bnx2x_set_qm_cid_count(struct bnx2x *bp)
 {
 	int cid_count = BNX2X_L2_MAX_CID(bp);

-#ifdef BCM_CNIC
-	cid_count += CNIC_CID_MAX;
-#endif
+	if (CNIC_ENABLED(bp))
+		cid_count += CNIC_CID_MAX;
 	return roundup(cid_count, QM_CID_ROUND);
 }

@@ -11743,7 +11722,8 @@ static int bnx2x_set_qm_cid_count(struct bnx2x *bp)
  * @dev:	pci device
  *
  */
-static int bnx2x_get_num_non_def_sbs(struct pci_dev *pdev)
+static int bnx2x_get_num_non_def_sbs(struct pci_dev *pdev,
+				     int cnic_enabled)
 {
 	int pos;
 	u16 control;
@@ -11755,7 +11735,7 @@ static int bnx2x_get_num_non_def_sbs(struct pci_dev *pdev)
 	 * one fast path queue: one FP queue + SB for CNIC
 	 */
 	if (!pos)
-		return 1 + CNIC_PRESENT;
+		return 1 + cnic_enabled;

 	/*
 	 * The value in the PCI configuration space is the index of the last
@@ -11767,6 +11747,15 @@ static int bnx2x_get_num_non_def_sbs(struct pci_dev *pdev)
 	return control & PCI_MSIX_FLAGS_QSIZE;
 }

+static int set_is_cnic_enabled(void)
+{
+#if defined(CONFIG_CNIC) || defined(CONFIG_CNIC_MODULE)
+	return 1;
+#else
+	return 0;
+#endif
+}
+
 static int __devinit bnx2x_init_one(struct pci_dev *pdev,
 				    const struct pci_device_id *ent)
 {
@@ -11775,6 +11764,7 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
 	int pcie_width, pcie_speed;
 	int rc, max_non_def_sbs;
 	int rx_count, tx_count, rss_count, doorbell_size;
+	int cnic_enabled;
 	/*
 	 * An estimated maximum supported CoS number according to the chip
 	 * version.
@@ -11815,21 +11805,22 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
 		return -ENODEV;
 	}

-	max_non_def_sbs = bnx2x_get_num_non_def_sbs(pdev);
+	cnic_enabled = set_is_cnic_enabled();
+	max_non_def_sbs = bnx2x_get_num_non_def_sbs(pdev, cnic_enabled);

 	WARN_ON(!max_non_def_sbs);

 	/* Maximum number of RSS queues: one IGU SB goes to CNIC */
-	rss_count = max_non_def_sbs - CNIC_PRESENT;
+	rss_count = max_non_def_sbs - cnic_enabled;

 	/* Maximum number of netdev Rx queues: RSS + FCoE L2 */
-	rx_count = rss_count + FCOE_PRESENT;
+	rx_count = rss_count + cnic_enabled;

 	/*
 	 * Maximum number of netdev Tx queues:
 	 * Maximum TSS queues * Maximum supported number of CoS  + FCoE L2
 	 */
-	tx_count = rss_count * max_cos_est + FCOE_PRESENT;
+	tx_count = rss_count * max_cos_est + cnic_enabled;

 	/* dev zeroed in init_etherdev */
 	dev = alloc_etherdev_mqs(sizeof(*bp), tx_count, rx_count);
@@ -11840,6 +11831,8 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,

 	bp->igu_sb_cnt = max_non_def_sbs;
 	bp->msg_enable = debug;
+	bp->cnic_enabled = cnic_enabled;
+
 	pci_set_drvdata(pdev, dev);

 	rc = bnx2x_init_dev(pdev, dev, ent->driver_data);
@@ -11880,14 +11873,10 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
 	/* calc qm_cid_count */
 	bp->qm_cid_count = bnx2x_set_qm_cid_count(bp);

-#ifdef BCM_CNIC
 	/* disable FCOE L2 queue for E1x */
 	if (CHIP_IS_E1x(bp))
 		bp->flags |= NO_FCOE_FLAG;

-#endif
-
-
 	/* Set bp->num_queues for MSI-X mode*/
 	bnx2x_set_num_queues(bp);

@@ -11905,14 +11894,12 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
 		goto init_one_exit;
 	}

-#ifdef BCM_CNIC
+	/* Add storage MAC address */
 	if (!NO_FCOE(bp)) {
-		/* Add storage MAC address */
 		rtnl_lock();
 		dev_addr_add(bp->dev, bp->fip_mac, NETDEV_HW_ADDR_T_SAN);
 		rtnl_unlock();
 	}
-#endif

 	bnx2x_get_pcie_width_speed(bp, &pcie_width, &pcie_speed);

@@ -11957,14 +11944,12 @@ static void __devexit bnx2x_remove_one(struct pci_dev *pdev)
 	}
 	bp = netdev_priv(dev);

-#ifdef BCM_CNIC
 	/* Delete storage MAC address */
 	if (!NO_FCOE(bp)) {
 		rtnl_lock();
 		dev_addr_del(bp->dev, bp->fip_mac, NETDEV_HW_ADDR_T_SAN);
 		rtnl_unlock();
 	}
-#endif

 #ifdef BCM_DCBNL
 	/* Delete app tlvs from dcbnl */
@@ -12015,9 +12000,9 @@ static int bnx2x_eeh_nic_unload(struct bnx2x *bp)

 	bp->rx_mode = BNX2X_RX_MODE_NONE;

-#ifdef BCM_CNIC
-	bnx2x_cnic_notify(bp, CNIC_CTL_STOP_CMD);
-#endif
+	if (CNIC_ENABLED(bp))
+		bnx2x_cnic_notify(bp, CNIC_CTL_STOP_CMD);
+
 	/* Stop Tx */
 	bnx2x_tx_disable(bp);

@@ -12212,7 +12197,6 @@ void bnx2x_notify_link_changed(struct bnx2x *bp)
 module_init(bnx2x_init);
 module_exit(bnx2x_cleanup);

-#ifdef BCM_CNIC
 /**
  * bnx2x_set_iscsi_eth_mac_addr - set iSCSI MAC(s).
  *
@@ -12762,5 +12746,4 @@ struct cnic_eth_dev *bnx2x_cnic_probe(struct net_device *dev)
 }
 EXPORT_SYMBOL(bnx2x_cnic_probe);

-#endif /* BCM_CNIC */

--
1.7.10

^ permalink raw reply related

* Re: [net-next patch] bnx2x: Add run-time CNIC support
From: David Miller @ 2012-07-08 10:31 UTC (permalink / raw)
  To: meravs; +Cc: netdev, eilong, dmitry
In-Reply-To: <1341740914-3181-1-git-send-email-meravs@broadcom.com>

From: "Merav Sicron" <meravs@broadcom.com>
Date: Sun, 8 Jul 2012 12:48:34 +0300

> This patch replaces the BCM_CNIC compilation flag with a run-time flag.
> This is mainly important for the SR-IOV driver, as this driver will share the
> same code with the PF/hypervisor driver. Since storage is not supported in
> SR-IOV (while is usually enabled in the non-SR-IOV driver), we don't want to
> waste resources on it.
> In addition this change makes the code prettier.
 ...
> -static const struct net_device_ops bnx2x_netdev_ops = {
> +static struct net_device_ops bnx2x_netdev_ops = {
 ...
> 
> +	if (CNIC_ENABLED(bp))
> +		bnx2x_netdev_ops.ndo_select_queue = bnx2x_select_queue;
> +#if defined(NETDEV_FCOE_WWNN)
> +	if (CNIC_ENABLED(bp))
> +		bnx2x_netdev_ops.ndo_fcoe_get_wwn = bnx2x_fcoe_get_wwn;
> +#endif
 ...
+static int set_is_cnic_enabled(void)
+{
+#if defined(CONFIG_CNIC) || defined(CONFIG_CNIC_MODULE)
+	return 1;
+#else
+	return 0;
+#endif
+}

This is basically a joke.

You're losing const'ness of net_device_ops and other nice things for
what is still, in the end, set by kconfig options.

I'm not applying crap like this, sorry.

^ permalink raw reply

* Re: [net-next patch] bnx2x: Add run-time CNIC support
From: Merav Sicron @ 2012-07-08 11:00 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, eilong, dmitry
In-Reply-To: <20120708.033122.2108511545126626834.davem@davemloft.net>

On Sun, 2012-07-08 at 03:31 -0700, David Miller wrote:
> From: "Merav Sicron" <meravs@broadcom.com>
> Date: Sun, 8 Jul 2012 12:48:34 +0300
> 
> > This patch replaces the BCM_CNIC compilation flag with a run-time flag.
> > This is mainly important for the SR-IOV driver, as this driver will share the
> > same code with the PF/hypervisor driver. Since storage is not supported in
> > SR-IOV (while is usually enabled in the non-SR-IOV driver), we don't want to
> > waste resources on it.
> > In addition this change makes the code prettier.
>  ...
> > -static const struct net_device_ops bnx2x_netdev_ops = {
> > +static struct net_device_ops bnx2x_netdev_ops = {
>  ...
> > 
> > +	if (CNIC_ENABLED(bp))
> > +		bnx2x_netdev_ops.ndo_select_queue = bnx2x_select_queue;
> > +#if defined(NETDEV_FCOE_WWNN)
> > +	if (CNIC_ENABLED(bp))
> > +		bnx2x_netdev_ops.ndo_fcoe_get_wwn = bnx2x_fcoe_get_wwn;
> > +#endif
>  ...
> +static int set_is_cnic_enabled(void)
> +{
> +#if defined(CONFIG_CNIC) || defined(CONFIG_CNIC_MODULE)
> +	return 1;
> +#else
> +	return 0;
> +#endif
> +}
> 
> This is basically a joke.
> 
> You're losing const'ness of net_device_ops and other nice things for
> what is still, in the end, set by kconfig options.
> 
> I'm not applying crap like this, sorry.
> 
It seems that I didn't explain our motivation well enough...
This feature is indeed not useful for the current bnx2x functionality.
However we are adding support for a VF driver to be used in SR-IOV, and
we will have single-binary bnx2x which will be used in both
PF/Hypervisor and VF (hopefully will send a patch on it in a couple of
weeks).
Since we want CNIC in the PF/Hypervisor but don't want CNIC in the VF,
and since it is a single binary, we can't use a compilation flag but
should rather use a run-time flag. 
The set_is_cnic_enabled function will eventually look something like
this:
static int set_is_cnic_enabled(bool is_vf)
{
        if (is_vf)
                return 0;
#if defined(CONFIG_CNIC) || defined(CONFIG_CNIC_MODULE)
        return 1;
#else
        return 0;
#endif
}

Thanks,
Merav

^ permalink raw reply

* Re: [net-next patch] bnx2x: Add run-time CNIC support
From: Eric Dumazet @ 2012-07-08 11:14 UTC (permalink / raw)
  To: Merav Sicron; +Cc: David Miller, netdev, eilong, dmitry
In-Reply-To: <1341745239.27284.13.camel@lb-tlvb-meravs.il.broadcom.com>

On Sun, 2012-07-08 at 14:00 +0300, Merav Sicron wrote:

> static int set_is_cnic_enabled(bool is_vf)
> {
>         if (is_vf)
>                 return 0;
> #if defined(CONFIG_CNIC) || defined(CONFIG_CNIC_MODULE)
>         return 1;
> #else
>         return 0;
> #endif
> }

Small note : this should use booleans and can use

if (is_vf)
	return false;

return IS_ENABLED(CONFIG_CNIC);

^ permalink raw reply

* [PATCH 1/7] drivers/isdn/mISDN/stack.c: remove invalid reference to list iterator variable
From: Julia Lawall @ 2012-07-08 11:37 UTC (permalink / raw)
  To: Karsten Keil; +Cc: kernel-janitors, netdev, linux-kernel
In-Reply-To: <1341747464-1772-1-git-send-email-Julia.Lawall@lip6.fr>

From: Julia Lawall <Julia.Lawall@lip6.fr>

If list_for_each_entry, etc complete a traversal of the list, the iterator
variable ends up pointing to an address at an offset from the list head,
and not a meaningful structure.  Thus this value should not be used after
the end of the iterator.  The dereferences are just deleted from the
debugging statement.

This problem was found using Coccinelle (http://coccinelle.lip6.fr/).

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/isdn/mISDN/stack.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/isdn/mISDN/stack.c b/drivers/isdn/mISDN/stack.c
index 1a0ae44..5f21f62 100644
--- a/drivers/isdn/mISDN/stack.c
+++ b/drivers/isdn/mISDN/stack.c
@@ -135,8 +135,8 @@ send_layer2(struct mISDNstack *st, struct sk_buff *skb)
 			skb = NULL;
 		else if (*debug & DEBUG_SEND_ERR)
 			printk(KERN_DEBUG
-			       "%s ch%d mgr prim(%x) addr(%x) err %d\n",
-			       __func__, ch->nr, hh->prim, ch->addr, ret);
+			       "%s mgr prim(%x) err %d\n",
+			       __func__, hh->prim, ret);
 	}
 out:
 	mutex_unlock(&st->lmutex);

^ permalink raw reply related

* [PATCH 2/7] net/rxrpc/ar-peer.c: remove invalid reference to list iterator variable
From: Julia Lawall @ 2012-07-08 11:37 UTC (permalink / raw)
  To: David S. Miller; +Cc: kernel-janitors, netdev, linux-kernel
In-Reply-To: <1341747464-1772-1-git-send-email-Julia.Lawall@lip6.fr>

From: Julia Lawall <Julia.Lawall@lip6.fr>

If list_for_each_entry, etc complete a traversal of the list, the iterator
variable ends up pointing to an address at an offset from the list head,
and not a meaningful structure.  Thus this value should not be used after
the end of the iterator.  This seems to be a copy-paste bug from a previous
debugging message, and so the meaningless value is just deleted.

This problem was found using Coccinelle (http://coccinelle.lip6.fr/).

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 net/rxrpc/ar-peer.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
index 2754f09..bebaa43 100644
--- a/net/rxrpc/ar-peer.c
+++ b/net/rxrpc/ar-peer.c
@@ -229,7 +229,7 @@ found_UDP_peer:
 	return peer;
 
 new_UDP_peer:
-	_net("Rx UDP DGRAM from NEW peer %d", peer->debug_id);
+	_net("Rx UDP DGRAM from NEW peer");
 	read_unlock_bh(&rxrpc_peer_lock);
 	_leave(" = -EBUSY [new]");
 	return ERR_PTR(-EBUSY);

^ permalink raw reply related

* [PATCH 6/7] drivers/net/ethernet/broadcom/cnic.c: remove invalid reference to list iterator variable
From: Julia Lawall @ 2012-07-08 11:37 UTC (permalink / raw)
  To: netdev; +Cc: kernel-janitors, linux-kernel
In-Reply-To: <1341747464-1772-1-git-send-email-Julia.Lawall@lip6.fr>

From: Julia Lawall <Julia.Lawall@lip6.fr>

If list_for_each_entry, etc complete a traversal of the list, the iterator
variable ends up pointing to an address at an offset from the list head,
and not a meaningful structure.  Thus this value should not be used after
the end of the iterator.  There does not seem to be a meaningful value to
provide to netdev_warn.  Replace with pr_warn, since pr_err is used
elsewhere.

This problem was found using Coccinelle (http://coccinelle.lip6.fr/).

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/net/ethernet/broadcom/cnic.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c
index 22ad7b6..6eaca60 100644
--- a/drivers/net/ethernet/broadcom/cnic.c
+++ b/drivers/net/ethernet/broadcom/cnic.c
@@ -542,7 +542,8 @@ int cnic_unregister_driver(int ulp_type)
 	}
 
 	if (atomic_read(&ulp_ops->ref_count) != 0)
-		netdev_warn(dev->netdev, "Failed waiting for ref count to go to zero\n");
+		pr_warn("%s: Failed waiting for ref count to go to zero\n",
+			__func__);
 	return 0;
 
 out_unlock:

^ permalink raw reply related

* Re: [net-next patch] bnx2x: Add run-time CNIC support
From: David Miller @ 2012-07-08 12:15 UTC (permalink / raw)
  To: meravs; +Cc: netdev, eilong, dmitry
In-Reply-To: <1341745239.27284.13.camel@lb-tlvb-meravs.il.broadcom.com>

From: "Merav Sicron" <meravs@broadcom.com>
Date: Sun, 8 Jul 2012 14:00:39 +0300

> static int set_is_cnic_enabled(bool is_vf)
> {
>         if (is_vf)
>                 return 0;
> #if defined(CONFIG_CNIC) || defined(CONFIG_CNIC_MODULE)
>         return 1;
> #else
>         return 0;
> #endif
> }

I still think this is beyond ugly.

This ifdef just wants to die completely.  It serves no real
purpose as every distribution vendor that turns on your driver
will turn CNIC on as well.

And you have to address the lost of const'ness of the netdevice ops.
If you absolutely must have runtime method choices, you must use
multiple instances of netdevice ops and assign the appropriate one.

^ permalink raw reply

* Re: [PATCH v5 4/7] ARM: davinci: net: davinci_emac: add OF support
From: Sekhar Nori @ 2012-07-08 14:26 UTC (permalink / raw)
  To: Heiko Schocher
  Cc: davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/,
	Wolfgang Denk, netdev-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Anatoly Sivov,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
In-Reply-To: <1338373143-7467-5-git-send-email-hs-ynQEQJNshbs@public.gmane.org>

Hi Heiko,

On 5/30/2012 3:49 PM, Heiko Schocher wrote:
> add of support for the davinci_emac driver.
> 
> Signed-off-by: Heiko Schocher <hs-ynQEQJNshbs@public.gmane.org>
> Cc: davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/@public.gmane.org
> Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
> Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
> Cc: Sekhar Nori <nsekhar-l0cyMroinI0@public.gmane.org>
> Cc: Wolfgang Denk <wd-ynQEQJNshbs@public.gmane.org>
> Cc: Anatoly Sivov <mm05-JGs/UdohzUI@public.gmane.org>
> 
> ---

> +#ifdef CONFIG_OF
> +static struct emac_platform_data
> +	*davinci_emac_of_get_pdata(struct platform_device *pdev,
> +	struct emac_priv *priv)
> +{
> +	struct device_node *np;
> +	struct emac_platform_data *pdata = NULL;
> +	const u8 *mac_addr;
> +	u32 data;
> +	int ret;
> +
> +	pdata = pdev->dev.platform_data;
> +	if (!pdata) {
> +		pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
> +		if (!pdata)
> +			goto nodata;
> +	}
> +
> +	np = pdev->dev.of_node;
> +	if (!np)
> +		goto nodata;
> +	else
> +		pdata->version = EMAC_VERSION_2;
> +
> +	mac_addr = of_get_mac_address(np);
> +	if (mac_addr)
> +		memcpy(pdata->mac_addr, mac_addr, ETH_ALEN);

I suspect that even in the DT case, many boards will continue to
read mac address from on-board EEPROMs or from an on-chip eFUSE.
To take care of such cases, I propose use mac address in DT data
only if no valid address is passed through platform data. The
attached patch does this change.

If you are OK with this modification, can you please merge it and
repost just this patch for review? Please CC David Miller
(davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org) on your next post as he is the netdev maintainer
and this patch needs to be merged through him or at least needs his ack.

With this modification, you can add my:

Acked-by: Sekhar Nori <nsekhar-l0cyMroinI0@public.gmane.org>

Thanks,
Sekhar

---8<----
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index 645618d..6b4b0fe 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -1795,9 +1795,11 @@ static struct emac_platform_data
 	else
 		pdata->version = EMAC_VERSION_2;
 
-	mac_addr = of_get_mac_address(np);
-	if (mac_addr)
-		memcpy(pdata->mac_addr, mac_addr, ETH_ALEN);
+	if (!is_valid_ether_addr(pdata->mac_addr)) {
+		mac_addr = of_get_mac_address(np);
+		if (mac_addr)
+			memcpy(pdata->mac_addr, mac_addr, ETH_ALEN);
+	}
 
 	ret = of_property_read_u32(np, "ti,davinci-ctrl-reg-offset", &data);
 	if (!ret)

^ permalink raw reply related

* Re: [PATCH 4/4] asix: Add a new driver for the AX88172A
From: Ben Hutchings @ 2012-07-08 15:50 UTC (permalink / raw)
  To: michael
  Cc: Christian Riesch, netdev, Oliver Neukum, Eric Dumazet, Allan Chou,
	Mark Lord, Grant Grundler, Ming Lei
In-Reply-To: <1341761975.2038.28.camel@schesaplana>

On Sun, 2012-07-08 at 17:39 +0200, Michael Riesch wrote:
> On Fri, 2012-07-06 at 18:37 +0100, Ben Hutchings wrote:
> > > +	priv->mdio->priv = (void *)dev;
> > > +	priv->mdio->read = &asix_mdio_bus_read;
> > > +	priv->mdio->write = &asix_mdio_bus_write;
> > > +	priv->mdio->name = "Asix MDIO Bus";
> > > +	snprintf(priv->mdio->id, MII_BUS_ID_SIZE, "asix-%s",
> > > +		 dev_name(dev->net->dev.parent));
> > [...]
> > 
> > I think you need to ensure that the bus identifier is unique throughout
> > its lifetime, but net devices can be renamed and that could lead to a
> > collision.  Perhaps you could use the ifindex or the USB device path
> 
> Ben,
> 
> the dev_name function in the code above returns the sysfs filename of
> the USB device (e.g. 1-0:1.0).
[...]

Sorry, I didn't read that carefully enough.

Ben.

-- 
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.

^ permalink raw reply

* Re: [PATCH 4/4] asix: Add a new driver for the AX88172A
From: Michael Riesch @ 2012-07-08 15:39 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: Christian Riesch, netdev, Oliver Neukum, Eric Dumazet, Allan Chou,
	Mark Lord, Grant Grundler, Ming Lei
In-Reply-To: <1341596255.2923.7.camel@bwh-desktop.uk.solarflarecom.com>

On Fri, 2012-07-06 at 18:37 +0100, Ben Hutchings wrote:
> > +	priv->mdio->priv = (void *)dev;
> > +	priv->mdio->read = &asix_mdio_bus_read;
> > +	priv->mdio->write = &asix_mdio_bus_write;
> > +	priv->mdio->name = "Asix MDIO Bus";
> > +	snprintf(priv->mdio->id, MII_BUS_ID_SIZE, "asix-%s",
> > +		 dev_name(dev->net->dev.parent));
> [...]
> 
> I think you need to ensure that the bus identifier is unique throughout
> its lifetime, but net devices can be renamed and that could lead to a
> collision.  Perhaps you could use the ifindex or the USB device path

Ben,

the dev_name function in the code above returns the sysfs filename of
the USB device (e.g. 1-0:1.0).

> (though that might be too long).

This may be a problem. The bus identifier may be 17 characters long, so
if we leave the endpoint/configuration part (:1.0) and the prefix away
it should be fine in any "normal" system. However, on a system with a
more-than-9-root-hubs 5-tier 127-devices-each USB infrastructure it
results in collisions. So is this approach acceptable?

Using the ifindex sounds good to me,

snprintf(priv->mdio->id, MII_BUS_ID_SIZE, "asix-%d",
	dev->net->ifindex);

works on any system with less than 10^12 network interfaces.

Regards,
Michael

^ permalink raw reply

* [PATCH] r6040: use module_pci_driver macro
From: Devendra Naga @ 2012-07-08 15:57 UTC (permalink / raw)
  To: Florian Fainelli, netdev; +Cc: Devendra Naga

as the manual of module_pci_driver says that
it can be used when the init and exit functions of
the module does nothing but the pci_register_driver
and pci_unregister_driver.

use it for rdc's r6040 driver, as the init and exit
paths does as above, and also this reduces a little
amount of code.

Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
---
 drivers/net/ethernet/rdc/r6040.c |   15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c
index 9acc026..557a265 100644
--- a/drivers/net/ethernet/rdc/r6040.c
+++ b/drivers/net/ethernet/rdc/r6040.c
@@ -1277,17 +1277,4 @@ static struct pci_driver r6040_driver = {
 	.remove		= __devexit_p(r6040_remove_one),
 };
 
-
-static int __init r6040_init(void)
-{
-	return pci_register_driver(&r6040_driver);
-}
-
-
-static void __exit r6040_cleanup(void)
-{
-	pci_unregister_driver(&r6040_driver);
-}
-
-module_init(r6040_init);
-module_exit(r6040_cleanup);
+module_pci_driver(r6040_driver);
-- 
1.7.9.5

^ permalink raw reply related

* Re: BISECTED: Re: REGRESSION: 3.4.0->3.5.0-rc2 kernel WARNING on cable plug on Acer Aspire One, no network
From: Alex Villacís Lasso @ 2012-07-08 17:14 UTC (permalink / raw)
  To: Marek Szyprowski; +Cc: 'Francois Romieu', netdev
In-Reply-To: <012601cd5a7b$886fd4c0$994f7e40$%szyprowski@samsung.com>

El 05/07/12 01:58, Marek Szyprowski escribió:
> Hello,
>
> On Thursday, July 05, 2012 6:15 AM Alex Villacís Lasso wrote:
>
>> El 04/07/12 02:02, Marek Szyprowski escribió:
>>> Hello,
>>>
>>> On Tuesday, July 03, 2012 4:27 PM Alex Villací¬s Lasso wrote:
>>>
>>>> El 03/07/12 00:40, Marek Szyprowski escribió:
>>>>> Hi Alex,
>>>>>
>>>>> On Tuesday, July 03, 2012 4:45 AM Alex Villacís Lasso wrote:
>>>>>
>>>>>> -------- Mensaje original --------
>>>>>> Asunto:  BISECTED: Re: REGRESSION: 3.4.0->3.5.0-rc2 kernel WARNING on cable
>>>>>> plug on Acer Aspire One, no network Fecha:  Mon, 02 Jul 2012 21:33:41 -0500 De:
>>>>>>     Alex Villacís Lasso <a_villacis@palosanto.com> Para:  Francois Romieu
>>>>>> <romieu@fr.zoreil.com> CC:  netdev@vger.kernel.org
>>>>>> El 01/07/12 08:50, Alex Villacís Lasso escribió:
>>>>>>> El 11/06/12 16:38, Francois Romieu escribió:
>>>>>>>> Alex Villacís Lasso <a_villacis@palosanto.com> :
>>>>>>>> [...]
>>>>>>>>> $ grep XID dmesg-3.5.0-rc2.txt
>>>>>>>>> [   15.873858] r8169 0000:02:00.0: eth0: RTL8102e at 0xf7c0e000,
>>>>>>>>> 00:1e:68:e5:5d:b1, XID 04a00000 IRQ 44
>>>>>>>> The 8102e has not been touched by that many suspect patches but I do
>>>>>>>> not see where the problem is :o(
>>>>>>>>
>>>>>>>> Can you peel off the r8169 patches between 3.4.0 and 3.5-rc ?
>>>>>>>>
>>>>>>> Still present in 3.5-rc5. Bisection still in progress.
>>>>>>>
>>>>>>> --
>>>>>>> To unsubscribe from this list: send the line "unsubscribe netdev" in
>>>>>>> the body of a message to majordomo@vger.kernel.org
>>>>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>>>> My full bisection points to this commit:
>>>>>>
>>>>>> commit 0a2b9a6ea93650b8a00f9fd5ee8fdd25671e2df6
>>>>>> Author: Marek Szyprowski <m.szyprowski@samsung.com>
>>>>>> Date:   Thu Dec 29 13:09:51 2011 +0100
>>>>>>
>>>>>>        X86: integrate CMA with DMA-mapping subsystem
>>>>>>
>>>>>>        This patch adds support for CMA to dma-mapping subsystem for x86
>>>>>>        architecture that uses common pci-dma/pci-nommu implementation. This
>>>>>>        allows to test CMA on KVM/QEMU and a lot of common x86 boxes.
>>>>>>
>>>>>>        Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
>>>>>>        Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
>>>>>>        CC: Michal Nazarewicz <mina86@mina86.com>
>>>>>>        Acked-by: Arnd Bergmann <arnd@arndb.de>
>>>>>>
>>>>>> Is this commit somehow messing with the network card DMA?
>>>>> This commit in fact touches DMA-mapping subsystem and introduces a bug,
>>>>> which has been finally fixed by commit c080e26edc3a2a3 merged to v3.5-rc3.
>>>>> After applying it the DMA-mapping subsystem should work exactly the same was
>>>>> as in v3.4. Could you please check if it fixes this issue?
>>>>>
>>>>> Best regards
>>>> No. It still fails in 3.5-rc5, as mentioned before.
>>> Hmm. I was a bit confused, because both the subject and git bisect log pointed to v3.5-rc2,
>>> which had that bug. Maybe there is one some other issue present in v3.5-rc5 not related to
>>> my patches?
>>>
>>> Could you check with v3.5-rc5 if reverting patch c080e26edc3a2a3cdfa4c430c663ee1c3bbd8fae
>>> and 0a2b9a6ea93650b8a00f9fd5ee8fdd25671e2df6 fixes the problems with rtl driver?
>>>
>>> Best regards
>> Reverting the two patches indeed fixes the bug on -rc5.
> That's really strange. Could you check if you have CMA disabled in the config? After preparing
> a c080e26edc3a2a3cdfa4c430c663ee1c3bbd8fae fixup patch, I was really convinced that there are
> no functional changes in x86 dma mapping code when CMA is disabled. I will provide some
> patches to revert different parts of my changes, so we will find which line causes issues.
>
> Best regards
I checked out v3.5-rc6 from git, without reverting any patches. I then 
compiled this release with my old config and verified the bug is 
currently fixed.

^ permalink raw reply

* Re: [PATCH 04/16] mm: allow PF_MEMALLOC from softirq context
From: Sebastian Andrzej Siewior @ 2012-07-08 18:12 UTC (permalink / raw)
  To: Mel Gorman
  Cc: Andrew Morton, Linux-MM, Linux-Netdev, LKML, David Miller,
	Neil Brown, Peter Zijlstra, Mike Christie, Eric B Munson,
	Eric Dumazet
In-Reply-To: <20120627082614.GE8271@suse.de>

On Wed, Jun 27, 2012 at 09:26:14AM +0100, Mel Gorman wrote:
> > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > > index b6c0727..5c6d9c6 100644
> > > --- a/mm/page_alloc.c
> > > +++ b/mm/page_alloc.c
> > > @@ -2265,7 +2265,11 @@ gfp_to_alloc_flags(gfp_t gfp_mask)
> > >  	if (likely(!(gfp_mask & __GFP_NOMEMALLOC))) {
> > >  		if (gfp_mask & __GFP_MEMALLOC)
> > >  			alloc_flags |= ALLOC_NO_WATERMARKS;
> > > -		else if (likely(!(gfp_mask & __GFP_NOMEMALLOC)) && !in_interrupt())
> > > +		else if (in_serving_softirq() && (current->flags & PF_MEMALLOC))
> > > +			alloc_flags |= ALLOC_NO_WATERMARKS;
> > > +		else if (!in_interrupt() &&
> > > +				((current->flags & PF_MEMALLOC) ||
> > > +				 unlikely(test_thread_flag(TIF_MEMDIE))))
> > >  			alloc_flags |= ALLOC_NO_WATERMARKS;
> > >  	}
> > 
> > You allocate in RX path with __GFP_MEMALLOC and your sk->sk_allocation has
> > also __GFP_MEMALLOC set. That means you should get ALLOC_NO_WATERMARKS in
> > alloc_flags.
> 
> In the cases where they are annotated correctly, yes. It is recordeed if
> the page gets allocated from the PFMEMALLOC reserves. If the received
> packet is not SOCK_MEMALLOC and the page was allocated from PFMEMALLOC
> reserves it is then discarded and the packet must be retransmitted.

Let me try again:
- lets assume your allocation happens with alloc_page(), without
  __GFP_MEMALLOC in GFP_FLAGS and with PF_MEMALLOC in current->flags. Now
  you may get memory which you wouldn't receive otherwise (without
  PF_MEMALLOC). Okay, understood. So you don't have to annotate each page
  allocation in your receive path for instance as long as the process has the
  flag set.
- lets assume your allocation happens with kmalloc() without __GFP_MEMALLOC
  and current->flags has PF_MEMALLOC ORed and your SLAB pool is empty. This
  forces SLAB to allocate more pages from the buddy allocator with it will
  receive more likely (due to ->current->flags + PF_MEMALLOC) but SLAB will
  drop this extra memory because the page has ->pf_memory (or something like
  that) set and the GFP_FLAGS do not have __GFP_MEMALLOC set.

Is there something I missed?

Sebastian

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply

* Re: [PATCH v2] cgroup: fix panic in netprio_cgroup
From: Eric Dumazet @ 2012-07-08 19:50 UTC (permalink / raw)
  To: Gao feng, nhorman; +Cc: davem, netdev, linux-kernel, tj, lizefan
In-Reply-To: <1341480520-25081-1-git-send-email-gaofeng@cn.fujitsu.com>

On Thu, 2012-07-05 at 17:28 +0800, Gao feng wrote:
> we set max_prioidx to the first zero bit index of prioidx_map in
> function get_prioidx.
> 
> So when we delete the low index netprio cgroup and adding a new
> netprio cgroup again,the max_prioidx will be set to the low index.
> 
> when we set the high index cgroup's net_prio.ifpriomap,the function
> write_priomap will call update_netdev_tables to alloc memory which
> size is sizeof(struct netprio_map) + sizeof(u32) * (max_prioidx + 1),
> so the size of array that map->priomap point to is max_prioidx +1,
> which is low than what we actually need.
> 
> fix this by adding check in get_prioidx,only set max_prioidx when
> max_prioidx low than the new prioidx.
> 
> Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
> ---
>  net/core/netprio_cgroup.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
> index 5b8aa2f..aa907ed 100644
> --- a/net/core/netprio_cgroup.c
> +++ b/net/core/netprio_cgroup.c
> @@ -49,8 +49,9 @@ static int get_prioidx(u32 *prio)
>  		return -ENOSPC;
>  	}
>  	set_bit(prioidx, prioidx_map);
> +	if (atomic_read(&max_prioidx) < prioidx)
> +		atomic_set(&max_prioidx, prioidx);
>  	spin_unlock_irqrestore(&prioidx_map_lock, flags);
> -	atomic_set(&max_prioidx, prioidx);
>  	*prio = prioidx;
>  	return 0;
>  }

This patch seems fine to me.

Acked-by: Eric Dumazet <edumazet@google.com>

Neil, looking at this file, I believe something is wrong.

dev->priomap is allocated by extend_netdev_table() called from
update_netdev_tables(). And this is only called if write_priomap() is
called.

But if write_priomap() is not called, it seems we can have out of bounds
accesses in cgrp_destroy() and read_priomap()

What do you think of following patch ?

diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
index 5b8aa2f..80150d2 100644
--- a/net/core/netprio_cgroup.c
+++ b/net/core/netprio_cgroup.c
@@ -141,7 +141,7 @@ static void cgrp_destroy(struct cgroup *cgrp)
 	rtnl_lock();
 	for_each_netdev(&init_net, dev) {
 		map = rtnl_dereference(dev->priomap);
-		if (map)
+		if (map && cs->prioidx < map->priomap_len)
 			map->priomap[cs->prioidx] = 0;
 	}
 	rtnl_unlock();
@@ -165,7 +165,7 @@ static int read_priomap(struct cgroup *cont, struct cftype *cft,
 	rcu_read_lock();
 	for_each_netdev_rcu(&init_net, dev) {
 		map = rcu_dereference(dev->priomap);
-		priority = map ? map->priomap[prioidx] : 0;
+		priority = (map && prioidx < map->priomap_len) ? map->priomap[prioidx] : 0;
 		cb->fill(cb, dev->name, priority);
 	}
 	rcu_read_unlock();

^ permalink raw reply related

* Re: [PATCH] r6040: use module_pci_driver macro
From: Florian Fainelli @ 2012-07-08 21:39 UTC (permalink / raw)
  To: Devendra Naga; +Cc: netdev
In-Reply-To: <1341763077-938-1-git-send-email-devendra.aaru@gmail.com>

Le dimanche 08 juillet 2012 17:57:57, Devendra Naga a écrit :
> as the manual of module_pci_driver says that
> it can be used when the init and exit functions of
> the module does nothing but the pci_register_driver
> and pci_unregister_driver.
> 
> use it for rdc's r6040 driver, as the init and exit
> paths does as above, and also this reduces a little
> amount of code.
> 
> Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>

Acked-by: Florian Fainelli <florian@openwrt.org>

> ---
>  drivers/net/ethernet/rdc/r6040.c |   15 +--------------
>  1 file changed, 1 insertion(+), 14 deletions(-)
> 
> diff --git a/drivers/net/ethernet/rdc/r6040.c
> b/drivers/net/ethernet/rdc/r6040.c index 9acc026..557a265 100644
> --- a/drivers/net/ethernet/rdc/r6040.c
> +++ b/drivers/net/ethernet/rdc/r6040.c
> @@ -1277,17 +1277,4 @@ static struct pci_driver r6040_driver = {
>  	.remove		= __devexit_p(r6040_remove_one),
>  };
> 
> -
> -static int __init r6040_init(void)
> -{
> -	return pci_register_driver(&r6040_driver);
> -}
> -
> -
> -static void __exit r6040_cleanup(void)
> -{
> -	pci_unregister_driver(&r6040_driver);
> -}
> -
> -module_init(r6040_init);
> -module_exit(r6040_cleanup);
> +module_pci_driver(r6040_driver);

-- 
Florian

^ permalink raw reply

* [RFC PATCH] ppp: add support for L2 multihop / tunnel switching
From: Benjamin LaHaise @ 2012-07-08 21:49 UTC (permalink / raw)
  To: netdev, linux-ppp

Hello folks,

Below is a first cut at implementing multihop L2TP, also known as tunnel 
switching.  The feature is similar in scope to how PPPoE relaying works -- 
L2 packets that are received on one PPP interface are forwarded to another.  
This feature is typically used for traffic aggregation and backhaul for 
ISPs, with incoming sessions (often PPPoE) being partially authenticated 
by a LAC, and then forwarded over an L2TP session to an LNS (selected by the 
user's domain) which then provides network access to the client.

This is an RFC primarily to get some feedback on the implementation 
approach being used.  At present, this code is intercepting packets as soon 
as they are received on a PPP channel.  The packets are then modified to 
use a fake ETH_P_PPP protocol type and sent out over another PPP device 
via dev_queue_xmit().  In theory this enables forwarding of any type of PPP 
session, although I've only tested L2TPv2 so far.

The reasoning behind using dev_queue_xmit() rather than outputting directly 
to another PPP channel is to enable the use of the traffic shaping and 
queuing features of the kernel on multihop sessions.

Comments / thoughts?  A sample test program is available at 
http://www.kvack.org/~bcrl/pppol2tp/multihop.c .  I am in the process of 
updating the Babylon PPP implementation to use this functionality, and 
expect to be ready to make those changes available later this week.  I 
have not yet finished testing this code, so I'm sure that there are bugs 
lurking within.

		-ben

Not-signed-off-yet-by: Benjamin LaHaise <bcrl@kvack.org>
---
 drivers/net/ppp/ppp_generic.c |   53 +++++++++++++++++++++++++++++++++++++++++-
 include/linux/if_ether.h      |    1 
 include/linux/ppp-ioctl.h     |    1 
 3 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 5c05572..9c12712 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -121,6 +121,7 @@ struct ppp {
 	unsigned long	last_xmit;	/* jiffies when last pkt sent 9c */
 	unsigned long	last_recv;	/* jiffies when last pkt rcvd a0 */
 	struct net_device *dev;		/* network interface device a4 */
+	struct net_device *multihop_if;	/* if to forward incoming frames to */
 	int		closing;	/* is device closing down? a8 */
 #ifdef CONFIG_PPP_MULTILINK
 	int		nxchan;		/* next channel to send something on */
@@ -738,6 +739,30 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		err = 0;
 		break;
 
+	case PPPIOCSMULTIHOP_IF:
+	{
+		struct net_device *multihop_if;
+		if (get_user(val, p))
+			break;
+		err = 0;
+		if (ppp->multihop_if && (val == -1)) {
+			struct net_device *dev = ppp->multihop_if;
+			ppp->multihop_if = NULL;
+			dev_put(dev);
+			break;
+		}
+		err = -EBUSY;
+		if (ppp->multihop_if)
+			break;
+		multihop_if = dev_get_by_index(&init_net, val);
+		err = -ENOENT;
+		if (!multihop_if)
+			break;
+		ppp->multihop_if = multihop_if;
+		err = 0;
+		break;
+	}
+
 #ifdef CONFIG_PPP_FILTER
 	case PPPIOCSPASS:
 	{
@@ -942,6 +967,9 @@ ppp_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	int npi, proto;
 	unsigned char *pp;
 
+	if (skb->protocol == htons(ETH_P_PPP))
+		goto queue;
+
 	npi = ethertype_to_npindex(ntohs(skb->protocol));
 	if (npi < 0)
 		goto outf;
@@ -968,6 +996,7 @@ ppp_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	proto = npindex_to_proto[npi];
 	put_unaligned_be16(proto, pp);
 
+queue:
 	skb_queue_tail(&ppp->file.xq, skb);
 	ppp_xmit_process(ppp);
 	return NETDEV_TX_OK;
@@ -1131,6 +1160,9 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
 	int len;
 	unsigned char *cp;
 
+	if (skb->protocol == htons(ETH_P_PPP))
+		goto xmit;
+
 	if (proto < 0x8000) {
 #ifdef CONFIG_PPP_FILTER
 		/* check if we should pass this packet */
@@ -1228,6 +1260,7 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
 		return;
 	}
 
+xmit:
 	ppp->xmit_pending = skb;
 	ppp_push(ppp);
 	return;
@@ -1259,7 +1292,8 @@ ppp_push(struct ppp *ppp)
 		return;
 	}
 
-	if ((ppp->flags & SC_MULTILINK) == 0) {
+	if (((ppp->flags & SC_MULTILINK) == 0) ||
+	    (skb->protocol == htons(ETH_P_PPP))) {
 		/* not doing multilink: send it down the first channel */
 		list = list->next;
 		pch = list_entry(list, struct channel, clist);
@@ -1599,6 +1633,14 @@ ppp_input(struct ppp_channel *chan, struct sk_buff *skb)
 		goto done;
 	}
 
+	if (pch->ppp && pch->ppp->multihop_if) {
+		skb->protocol = htons(ETH_P_PPP);
+		skb->dev = pch->ppp->multihop_if;
+		skb->ip_summed = CHECKSUM_NONE;
+		dev_queue_xmit(skb);
+		goto done;
+	}
+
 	proto = PPP_PROTO(skb);
 	if (!pch->ppp || proto >= 0xc000 || proto == PPP_CCPFRAG) {
 		/* put it on the channel queue */
@@ -2715,8 +2757,12 @@ static void ppp_shutdown_interface(struct ppp *ppp)
 	/* This will call dev_close() for us. */
 	ppp_lock(ppp);
 	if (!ppp->closing) {
+		struct net_device *multihop_if = ppp->multihop_if;
 		ppp->closing = 1;
+		ppp->multihop_if = NULL;
 		ppp_unlock(ppp);
+		if (multihop_if)
+			dev_put(multihop_if);
 		unregister_netdev(ppp->dev);
 		unit_put(&pn->units_idr, ppp->file.index);
 	} else
@@ -2764,6 +2810,11 @@ static void ppp_destroy_interface(struct ppp *ppp)
 #endif /* CONFIG_PPP_FILTER */
 
 	kfree_skb(ppp->xmit_pending);
+	printk("ppp_destroy_interface(%p): multihop_if = %p\n", ppp,
+		ppp->multihop_if);
+	if (ppp->multihop_if)
+		dev_put(ppp->multihop_if);
+	ppp->multihop_if = NULL;
 
 	free_netdev(ppp->dev);
 }
diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
index 167ce5b..fe47a70 100644
--- a/include/linux/if_ether.h
+++ b/include/linux/if_ether.h
@@ -120,6 +120,7 @@
 #define ETH_P_PHONET	0x00F5		/* Nokia Phonet frames          */
 #define ETH_P_IEEE802154 0x00F6		/* IEEE802.15.4 frame		*/
 #define ETH_P_CAIF	0x00F7		/* ST-Ericsson CAIF protocol	*/
+#define ETH_P_PPP	0x00F8		/* Dummy type for PPP multihop	*/
 
 /*
  *	This is an Ethernet frame header.
diff --git a/include/linux/ppp-ioctl.h b/include/linux/ppp-ioctl.h
index 2d9a885..5571375 100644
--- a/include/linux/ppp-ioctl.h
+++ b/include/linux/ppp-ioctl.h
@@ -81,6 +81,7 @@ struct pppol2tp_ioc_stats {
  * Ioctl definitions.
  */
 
+#define	PPPIOCSMULTIHOP_IF	_IOWR('t', 91, int) /* set multihop if */
 #define	PPPIOCGFLAGS	_IOR('t', 90, int)	/* get configuration flags */
 #define	PPPIOCSFLAGS	_IOW('t', 89, int)	/* set configuration flags */
 #define	PPPIOCGASYNCMAP	_IOR('t', 88, int)	/* get async map */
-- 
"Thought is the essence of where you are now."

^ permalink raw reply related

* Re: [PATCH v2] cgroup: fix panic in netprio_cgroup
From: Gao feng @ 2012-07-09  0:16 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: nhorman, davem, netdev, linux-kernel, tj, lizefan
In-Reply-To: <1341777043.3265.1786.camel@edumazet-glaptop>

于 2012年07月09日 03:50, Eric Dumazet 写道:
> On Thu, 2012-07-05 at 17:28 +0800, Gao feng wrote:
>> we set max_prioidx to the first zero bit index of prioidx_map in
>> function get_prioidx.
>>
>> So when we delete the low index netprio cgroup and adding a new
>> netprio cgroup again,the max_prioidx will be set to the low index.
>>
>> when we set the high index cgroup's net_prio.ifpriomap,the function
>> write_priomap will call update_netdev_tables to alloc memory which
>> size is sizeof(struct netprio_map) + sizeof(u32) * (max_prioidx + 1),
>> so the size of array that map->priomap point to is max_prioidx +1,
>> which is low than what we actually need.
>>
>> fix this by adding check in get_prioidx,only set max_prioidx when
>> max_prioidx low than the new prioidx.
>>
>> Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
>> ---
>>  net/core/netprio_cgroup.c |    3 ++-
>>  1 files changed, 2 insertions(+), 1 deletions(-)
>>
>> diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
>> index 5b8aa2f..aa907ed 100644
>> --- a/net/core/netprio_cgroup.c
>> +++ b/net/core/netprio_cgroup.c
>> @@ -49,8 +49,9 @@ static int get_prioidx(u32 *prio)
>>  		return -ENOSPC;
>>  	}
>>  	set_bit(prioidx, prioidx_map);
>> +	if (atomic_read(&max_prioidx) < prioidx)
>> +		atomic_set(&max_prioidx, prioidx);
>>  	spin_unlock_irqrestore(&prioidx_map_lock, flags);
>> -	atomic_set(&max_prioidx, prioidx);
>>  	*prio = prioidx;
>>  	return 0;
>>  }
> 
> This patch seems fine to me.
> 
> Acked-by: Eric Dumazet <edumazet@google.com>
> 
> Neil, looking at this file, I believe something is wrong.
> 
> dev->priomap is allocated by extend_netdev_table() called from
> update_netdev_tables(). And this is only called if write_priomap() is
> called.
> 
> But if write_priomap() is not called, it seems we can have out of bounds
> accesses in cgrp_destroy() and read_priomap()

Agree,and the function skb_update_prio has the same problem.

^ permalink raw reply

* [PATCH firmware 2/4] rtl_nic: update firmware for RTL8411
From: Hayes Wang @ 2012-07-09  3:11 UTC (permalink / raw)
  To: dwmw2, ben; +Cc: romieu, netdev, linux-kernel, Hayes Wang
In-Reply-To: <1341803512-1309-1-git-send-email-hayeswang@realtek.com>

File: rtl_nic/rtl8411-1.fw
Version: 0.0.3

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
---
 WHENCE               |    2 +-
 rtl_nic/rtl8411-1.fw |  Bin 1840 -> 2112 bytes
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/WHENCE b/WHENCE
index 676ebb1..c7a3e98 100644
--- a/WHENCE
+++ b/WHENCE
@@ -1808,7 +1808,7 @@ File: rtl_nic/rtl8168f-2.fw
 Version: 0.0.4
 
 File: rtl_nic/rtl8411-1.fw
-Version: 0.0.2
+Version: 0.0.3
 
 File: rtl_nic/rtl8402-1.fw
 Version: 0.0.1
diff --git a/rtl_nic/rtl8411-1.fw b/rtl_nic/rtl8411-1.fw
index 1bd9e7cdd5605e34e0322c0df185c53e46d6a34b..72772dbc8343c8cef8eac61f704377fc3fb6c7b3 100644
GIT binary patch
delta 430
zcmZ{fze@sP7{~8U`4Wj`Q4Iy9WLe;k_wMStjzDN>X^@6!a}JuKp{*}UOVSiH7DS^R
zg*4kA(2!HBf)TW|m6Sx!NkK~wyga|3@8`W9xQi7uvE98Lcfm9>W>IBT){ZMDXSzAl
z3VMMBL!Y{)O=uhIj-}k9rA$jX%FSAF)Akl^&s^4yFO$LSP2pZ2E7w6|1x$FL-T-@f
zzGfMly5W~<N1^`E!D<=w4DdApew~8hF4*jVhZS)4N@4{%P4O+TwFKs+9-9KE&%jC>
ztmeT;Tr{c@N5R1vFeR}+B-+E^Z5oXFU`aImXQ}mpk5UUsEp6a{-50PE7Jv_FZVP|_
zHAS#B0*;CgAR4k%p9I%3|HGza?ja{PBC_L(;Fi37FnKPZ!95GKf8fUjz8wRtijefg
X=D>LwO211kzk2%3-~Q$&7btxL90!Z?

delta 157
zcmX>guz@dt0SJmpax6>?4RsCU4fG83j1&xv^^MH+4UIr@AOKRdg^_{5mLbT;%*enZ
z-pIhv$iUdhP{Gj5%EZjd)PSLPi3&(%_y3InXBfqr_OmrGtz&CYv|?*uyvWu7=5O3=
o#1zKJRHL)Gi<yg=Z%Y$fgB257!+S-xhJVv0?_+P`0hs^;0L0HE{{R30

-- 
1.7.10.2

^ permalink raw reply related

* [PATCH firmware 1/4] rtl_nic: update firmware for RTL8168F
From: Hayes Wang @ 2012-07-09  3:11 UTC (permalink / raw)
  To: dwmw2, ben; +Cc: romieu, netdev, linux-kernel, Hayes Wang

File: rtl_nic/rtl8168f-1.fw
Version: 0.0.5

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
---
 WHENCE                |    2 +-
 rtl_nic/rtl8168f-1.fw |  Bin 3136 -> 3424 bytes
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/WHENCE b/WHENCE
index 13cbcab..676ebb1 100644
--- a/WHENCE
+++ b/WHENCE
@@ -1802,7 +1802,7 @@ File: rtl_nic/rtl8168e-3.fw
 Version: 0.0.4
 
 File: rtl_nic/rtl8168f-1.fw
-Version: 0.0.4
+Version: 0.0.5
 
 File: rtl_nic/rtl8168f-2.fw
 Version: 0.0.4
diff --git a/rtl_nic/rtl8168f-1.fw b/rtl_nic/rtl8168f-1.fw
index 41822b54ef44c37400db3ddac26d0e6655e1faa7..bf7883163e3dbed22420dec369ed51a3ee8247d4 100644
GIT binary patch
delta 487
zcmZuuJxc>Y6uex*5QyRjDq^7#zab`j7d#Ie(Z)hSv9hxh0;$A8M9Cne3RVFdK??;z
zG${E2T3MUY$_vCgor;J!CkhrWEbqP9dGls>?|Os26-#S#EAKm=zcJ~oo3u$!C5@MH
z{EXv<hgu<NK5AKcYjw$UT{E}t8pk!B@zZY7$<9n=XN+SV9EIGQmAKt;Rs?+;tnGof
z5%9d6vrkbJV)s-#qfaq&1@8G^q$a2dwzPxS9boH+8Wb=73RtSEgYm^^;ra(|O84^+
zjENq+fyELyD#^frUZ7Y9>(k(@@b&?4=ol<Dz{^=Mkpu@XmA8UzBjA|wibmR<;6h3k
zD$<kF%CfLHm=hKima<Xc$1eC51Do$U%z=3s3N*0Z1$HZjCTeQB?FS##7(T*(X2-;P
z$Vejr?t9v6+S}mpiHwGNE|~o>-zW18y^mXx;P<d`a6+Wit7_fq`L}-gTbFkd_p$It
Fz5vSno%R3#

delta 196
zcmaDLbwDD30SJmpax4tZEYfrh;|=r-^h^{CjP;Go^$m?cl0X1b^qYx+VJ<_EkC~B?
zfn&UpfuWIsv5}#Ip_!G5nU#?xL+=t5kkSbo12~uj#ah`KEST6DF4nR&>}O<aker;!
zw3tl?D8j_IS%~>Qi-9~_L#+i{1LH-Y(0jH99s#z74T5Y9ynlcifV2#<0SrL?W<?Hf
TW<DjT@Oz-S|E5iz#&Zk+TtzbT

-- 
1.7.10.2

^ permalink raw reply related

* =? ?q?=5BPATCH=20firmware=203/4=5D=20rtl=5Fnic=3A=20add=20new=20firmware=20for=20RTL8106E?=
From: Hayes Wang @ 2012-07-09  3:11 UTC (permalink / raw)
  To: dwmw2, ben; +Cc: romieu, netdev, linux-kernel, Hayes Wang
In-Reply-To: <1341803512-1309-1-git-send-email-hayeswang@realtek.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="\"\"", Size: 2104 bytes --]

File: rtl_nic/rtl8106e-1.fw
Version: 0.0.1

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
---
 WHENCE                |    3 +++
 rtl_nic/rtl8106e-1.fw |  Bin 0 -> 1856 bytes
 2 files changed, 3 insertions(+)
 create mode 100644 rtl_nic/rtl8106e-1.fw

diff --git a/WHENCE b/WHENCE
index c7a3e98..8f2b610 100644
--- a/WHENCE
+++ b/WHENCE
@@ -1813,6 +1813,9 @@ Version: 0.0.3
 File: rtl_nic/rtl8402-1.fw
 Version: 0.0.1
 
+File: rtl_nic/rtl8106e-1.fw
+Version: 0.0.1
+
 Licence:
  * Copyright © 2011, Realtek Semiconductor Corporation
  *
diff --git a/rtl_nic/rtl8106e-1.fw b/rtl_nic/rtl8106e-1.fw
new file mode 100644
index 0000000000000000000000000000000000000000..85694cb6bf5f0a1807356392497703a779b5148e
GIT binary patch
literal 1856
zcmZ{lYlxIp7{||CawkZ3{NN2d?SMi<kiIk6ZtjOz!(u_ZfSV}_Gv%%qTtXJ{lWtFC
zAmnxtFA!a(8Y+@B(#j}t>x&;G)KF7QP>}FL6lNbnrS12B-}AD=L<0}cdCz&C|MPz?
z=ZtgCjcgfys1kJ#Jy5Ad^P~BdQq;Ymx@bYA%9(z3<m-%cXWa8^w+z>0TdPKuYSdkM
zur@fdaqG}XsnXLME$m&`<Hnlv<P+2zdDmr<&6{VNn=;4Tes5P^@aC3z>*zx-LHfOQ
zZA<ow%h7dYgSUs*qg^6h&v?6C^OpbA+sf7KJ?m{o<ZY0(VSno*Z<l`YHXZxv-*}t$
zrMFFIymj*3d4%<8Z&O)M`NCU9u~vd5y~bM+9PMSoUY<Q+k0O5|?^P1cbvWnX<+dXm
zy_JU0U`ld_hzqA)?DyBPhwnY$?LrLR_qF7xT#I129o{0=CG3y4oo6`D9`&{yyaF}_
z#SO8F^5^^1d2HDG#}a;qkIqy(`ADZebNQaT#@oI9leHF)tbC~X#Eag(Csy2>$GuhC
z?8G<5gzK@Ux5F2SOKjPfuy>=#bJQ?kjI;O7>A;Wr%g)$S&GTSn;Z|<xZ;CzK7FTu1
z?VZHe9DGYX?+SBZ>IHRwi@5PD@U3|`@FQ~qzcKU*^d|TYpc`<yAbk>C^l#?vV|<Sw
z;&_F4?YS31?u9zBUWPmKrP<gJd>Z6cUdI`DlEw;pzX}b{CUNrYiHCZ1$C5aW6mxLW
zFP<yvlKU#@W3f)J$fxUR>K$@6>ZjS&9r&5}>9=zKzZr{X0xab>PTV+7OI+1+UR&Ms
zvU>?1#Ty7dE%UCLrM-4fOy1@A{*puM-R-1j6M_F~-G|V#4(`?Z@U5QZ_7Eq`(TCLQ
zy7Tr5`d762cMW}QA2x0H@eIP@GH3Z$!+m)QyaQooS!eJWZJD=im%RNBp89o_y7b}S
zLk(sv@pfWyQY-ECh5U6_G>fVJ;dT1^leeY#=XZO1q`};fkKPO6)$x5Byz*lSmcGm6
zrtcK9{T;ea+!R06pAcs;Z`S?bFAMKb1FS53vT*H3_7Eqvm(Ia6?Pmw;Kfs+p-VAoy
zlif_T-k`r<OL86~);V(Ne4iejrFP_I=e!+7XFs4<#E<VUF}2=-%}vgvZ=jWXe23td
z=C~8vQ^Zcs#yPv$#`kV`6dp}Dd=7_M)b${EP4v6yogr_-H@%x_FQ(yJCWhkm4bUTW
z>pQNR9&Yj$1&q>@|DB(7KK0+C`P6&z8TRpP*1i4t9hl^%|1p=HW0C&LwC49OflNUk

literal 0
HcmV?d00001

-- 
1.7.10.2

^ permalink raw reply related

* =? ?q?=5BPATCH=20firmware=204/4=5D=20rtl=5Fnic=3A=20add=20new=20firmware=20for=20RTL8168G?=
From: Hayes Wang @ 2012-07-09  3:11 UTC (permalink / raw)
  To: dwmw2, ben; +Cc: romieu, netdev, linux-kernel, Hayes Wang
In-Reply-To: <1341803512-1309-1-git-send-email-hayeswang@realtek.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="\"\"", Size: 3800 bytes --]

File: rtl_nic/rtl8168g-1.fw
Version: 0.0.1

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
---
 WHENCE                |    3 +++
 rtl_nic/rtl8168g-1.fw |  Bin 0 -> 4272 bytes
 2 files changed, 3 insertions(+)
 create mode 100644 rtl_nic/rtl8168g-1.fw

diff --git a/WHENCE b/WHENCE
index 8f2b610..1fb7951 100644
--- a/WHENCE
+++ b/WHENCE
@@ -1816,6 +1816,9 @@ Version: 0.0.1
 File: rtl_nic/rtl8106e-1.fw
 Version: 0.0.1
 
+File: rtl_nic/rtl8168g-1.fw
+Version: 0.0.1
+
 Licence:
  * Copyright © 2011, Realtek Semiconductor Corporation
  *
diff --git a/rtl_nic/rtl8168g-1.fw b/rtl_nic/rtl8168g-1.fw
new file mode 100644
index 0000000000000000000000000000000000000000..dace1ea98c66de08107ee0857d8a8680d57d7898
GIT binary patch
literal 4272
zcma)=4Q!QH8OP6kds{wM$}K%Y`H<dLC`AQsTT|vXp)D<277}sMEg(r-8Eiyx70{Tt
zg@+5Q`*4D8GRDSMM{zKrWJV2H7`HfNer#-IQFJ8p!hjiry~bsQF`)jQd(PWlnweNQ
zdCqyx^YK6b^PF?u))-^ftozoD)pa-CGpo8KF*`B4I-aPTQ}e|+)iuoNPb;lBYRsMH
zjzx7fHMI>bYuZ+~EWhvW6)o*;>z3c!QeBg%P1LolUbS|4yt?kDnlJF*JodEuCT}Pc
zV`BWv{_m0O*tAECNvo>fn0UPjI`1}St1<bB1*6Mk;f4}1pRp1@SR%2&it4n#mHxO+
z=8P4KjDFtAWZDW^!7M9NPg?m&y_M+8RyHN9^iQ$!ChZ;CK)03P0BsBXA6bbUx6+=r
zV#d-(A3;A3|9`X$*+sBBi|>DCSXug(l^wlSMq#t1)yg*+Kf-uAxewES$oEGwzeX_}
zu`-vr@6nI>{&(mHzTZwi;`?8p;NotrwNkUp%B}dRPGddZ=H_;S>rs4kjg77N{%Xi(
zE#pJXFU0R(l~&}JRvPxe-xK8SaQ+t>t*pjw#0e{lvCBgakniR@t$eq}%3b$csmCuM
z?#;y5hOLeZ{P<+Gl~!+4<aIG*@Q|}BdcyfB_sV&&*Ge&1o9n?tKac%*X$iKw!Txh_
zF}HxZn78XBU+o`he*!zYAAoUy@c`p;#)03jSk8W}oPeG^>Og9|XNaNvbgj4Y2L5Nj
z5%qrYVSZ8kny^>9IG92_FEbvS24g<8fPdtmi`iOl<*1L_hhA+0ZxeW%wokB$VxzI2
zYP}xYdiLJ@*2?^&aPvBOUck=dC?!tpDcWW@uX4HmSDcY>`N01ft8ymi1FlX{&!&gw
z{miTM!C`(!J7(p`YslZzz-2~~-|s_2_u*l5f1sf=?2XPxS-(o<UOA0!cjHf5x7vm4
z+&+vGU9Zk--DtgB*8SsLYn;Q_wx-#uQLes{?33nOj@@k&Ig3?J|H@1-?!kW-+-{<N
zHgJxT@cTTi$HnTz=Tl>>s4V=Fi?fKm{mp0bBS#Q8yRGEZ9Q*uSAu$xokB8}th@U23
zSVudD&Bs|+-aS@kv6gv18^U4gIkVX6-8H`pJ#+CMm!q8XHV=$FU@RDhF?)u*U4$56
zz3%=rHOije3r<~sob`uws&j$&(Y(q@jQMhM=IY}cIIpy=*b8$v(dw~HfG_6#PlM^u
zXvfVDJvYL9!sk_<3*l*6gIi0y&FyIwYr2oMtYW<p_GkrC`BXfmX)py=E|E{b74^A>
zbCl0~6?k&z4{czr<W|ga<_=*~@BKrpDu?r^b)q<%8o>i!8dGaeaXt%9#U?FIHws-R
zx-O6Xaisd^;>fM-9j({bPFUNM{QFga{0kgLksppA7V`B1xImt|$U1V~zRry$vXM9H
zz&<MnH(J+!!^+$AqXE7<tnB4nY@&bQYgVox<NML)@y0#K9{c_))M171_e{1jftbO2
zRxV;wN<Z=q>KF{S!RIZEFRkJXe#Cxd;Gqw@n3H8C<n86&P2vAfD@z*blQZ>wE3bBd
z5#HXaV6M>09n7h3CwNspdfdqm@z?QQ-XWEv-*z(gZzs2WU}XdPsSzh{zro4-iK+Va
z<KT)I`hC#%Yu;Z$QiBhxY~ro<<EQ=j8I><s*^NAb42+ePMOHTBpWz+5whi8{qK{hn
zHua}m2H5?Ae1+OSiXHti+8@a~HOA?q)WqdWj-%vh?ut29CUFNP)AXldTMp;l4rl*e
zd`~c*mV|4tHz|LtU-^q+GmhB(i>#c(e-1Vpqn{X|&o=hq$~E>S%AC(t%AGZstHMep
zakAJi5SRTP%=2fLrzo6%*UC=jHBLX6&k^UkoWxR`(JQ>8)Ic%3RZ}}B^1<x6i^A7O
ztUYs?x}jFoMr$p#jQe^4-zfncJjpj&6>q(+^@x=x8#!P5uwnmR%dv@KW2k`<;446G
zK0tlnPF!kO<5p_i>8zpI#XUpZwVIE8nA?vHat^Ybx(;4+e99U2YaQ!@^T~6qyof9z
zUO<lEb5@GL7ktIl!C3m4T|;%C91qrh+RA?L*3R(jIGnSNQM{La9s9vl&N`ZPtxKFu
z$9r%#Kz;)kU@s;{2b`za$5S0{En~1v6<c}Nk28$JdQ=?BZ!i3&h!Ogvuo-Tzd)3j$
zn?gR75nn6e{xl@@egPYM`1j4MA08rpymS)0D=#{Rqw|b&>n-FWTa(nM*5pj$Nt$(W
zF9a2Q>*BBT7g?ju&tN{g?<J0la_Tob9`DA*oTu`sUN_O{#(7=xyp`wSb+qv{N=!W$
z8nZFX)8z6rp<5Wh5BlkTFEZ>!3Jg>HxRCKw_E2?YxjL|^t}0h&o$e*#YYk_8!F(RO
zMsg+l;H|;&a}|!2_rW`W^>;3`k`L|&@$G(uF?VWS#L7g*8P=(LJKU#VIgJnFlzd+e
z*Q%T{pIyJ!7yJyKr3&iY<3GnbZv~^Cv0m&`d7LRf*GJ7PWbQQBG)@)gC3y~v#O@_m
zidqY8yRq%%o=Z_Hp)QS1xsG4N?<^SLr<=8A`9S8@OIULy!absAcZ!wwI~<>SPD(f@
z9cj3MJLO8>k8bXuPHHJ1uCn7>IR9Wskh4;;k~5PS;xEnJ)685&h^N`%$<{t`b2$z^
z<~{-AV#UJQKMNMU8+Cv6Ea_O^6CLY1vvGaSz{l13?3?$#yGxVc?+4G>N{2DSxeNDJ
z@5SSsTjk+n&aV2M+y!^6b>d%Xf1|xaJB7^%xcsS$IiG$Mn+wmO_wlYBb8nMjf12UO
zJb+|h%`)O*Yu@Axss781RnME!F$&3@pOxfOyROr`&B&v1=En1FsJ`Gd?N(+V<Zax}
zH!$@&Z;zEdi@ERSSvhuy@2LvzPB1if;R`1H&KZ9cJ$CwgL@D1YAHdrrWbXvd9CB$X
t=MA}%J=AZRGUoO7cw^k}@8RDC2CkYoe+TFp{JkGc;aq0G&6%8^{{jgy%S-?O

literal 0
HcmV?d00001

-- 
1.7.10.2

^ permalink raw reply related

* RE: [PATCH 0/4] Add a driver for the ASIX AX88172A
From: ASIX Allan Email [office] @ 2012-07-09  2:38 UTC (permalink / raw)
  To: 'Christian Riesch', netdev
  Cc: 'Oliver Neukum', 'Eric Dumazet',
	'Mark Lord', 'Grant Grundler', 'Ming Lei',
	'Michael Riesch', ASIX Louis [蘇威陸],
	ASIX Freddy [辛恆豐]
In-Reply-To: <1341574388-7464-1-git-send-email-christian.riesch@omicron.at>

Dear All,

Thanks a lot for your great efforts to support AX88172A on Linux kernel mainline source.  

The following information might be useful for you to implement AX88172A Linux driver in Linux kernel mainline source. Most of AX88172A customers' applications will implement their target applications through the MII interface in MAC mode or through the Rev-MII/Rev-RMII in PHY mode, such as AX88172A (MAC mode) + external fiber PHY, AX88172A (PHY mode or Dual-PHY mode) + external MAC controller, etc. ASIX uses AX88172A EEPROM offset 17h (as Software Field setting, the AX88172A drivers will check this field value to identify the exact applications for different driver initialization procedures) to identify different customers' applications. 

For the AX88172A (PHY mode or Dual-PHY mode) + external MAC controller customers' applications that are embedded applications with AX88172A on-board design, customers should have implemented ASIX's AX88172A Linux driver source on their own embedded Linux kernel platform directly. 

For the AX88172A (MAC mode) + external fiber PHY applications that might be USB to Fiber dongle applications, users might plug the USB to Fiber dongle on any Linux kernel platforms. You can consider referring to ASIX's AX88172A Linux driver source that can be downloaded from AX88172A Driver Download web page (http://www.asix.com.tw/download.php?sub=driverdetail&PItemID=96) to support these kinds of known dongle solutions on Linux kernel mainline source if necessary. Please feel free to let us know if you need more information. Thanks a lot.
 

---
Best regards,
Allan Chou
Technical Support Division
ASIX Electronics Corporation
TEL: 886-3-5799500 ext.228
FAX: 886-3-5799558
E-mail: allan@asix.com.tw 
http://www.asix.com.tw/ 

-----Original Message-----
From: Christian Riesch [mailto:christian.riesch@omicron.at] 
Sent: Friday, July 06, 2012 7:33 PM
To: netdev@vger.kernel.org
Cc: Oliver Neukum; Eric Dumazet; Allan Chou; Mark Lord; Grant Grundler; Ming Lei; Michael Riesch; Christian Riesch
Subject: [PATCH 0/4] Add a driver for the ASIX AX88172A

Hi,

this patch adds a driver for the ASIX AX88172A USB 2.0 to 10/100M
Fast Ethernet Controller.

Although this chip is already supported by the AX88772 code in
drivers/net/usb/asix.c, I submit a new driver since the existing
driver lacks an important feature: It only supports an
Ethernet connection using the internal PHY embedded in the AX88172A.

The driver for the AX88172A is based on drivers/net/usb/asix.c
and the work of Michael Riesch <michael@riesch.at>.

The first patch in the patchset fixes checkpatch warnings in asix.c.

The second and the third patch factor out common code which is shared
between the existing drivers and the new driver for the AX88172A.

The fourth patch finally adds support for the AX88172A.

The patchset applies on top of net-next.

I have a few questions:

1) Is it ok to factor out the common code like I did? Or should
   it go into a separate kernel module?

2) phylib/usbnet: Currently I have an empty .status function
   in my const struct driver_info ax88172a_info. I think this
   notifies me of a link change, right? I don't know
   what I should do in this function. Trigger the phy state machine
   like a phy interrupt would do, since link changes are handled
   by the phy state machine?

I have tested the patch with the ASIX AX88172A demo board (using the
internal PHY) and a custom board (AX88172A and National DP83640 PHY).

I am looking forward to your comments. Since this is my first submission
of a larger patchset to a kernel mailing list, I would like to thank you
in advance for your patience :-) The patch is in an early state and
certainly needs improvement!

Regards, Christian

Christian Riesch (4):
  asix: Fix checkpatch warnings
  asix: Rename asix.c to asix_devices.c
  asix: Factor out common code
  asix: Add a new driver for the AX88172A

 drivers/net/usb/Makefile       |    1 +
 drivers/net/usb/asix.c         | 1660 ----------------------------------------
 drivers/net/usb/asix.h         |  211 +++++
 drivers/net/usb/asix_common.c  |  525 +++++++++++++
 drivers/net/usb/asix_devices.c | 1033 +++++++++++++++++++++++++
 drivers/net/usb/ax88172a.c     |  407 ++++++++++
 6 files changed, 2177 insertions(+), 1660 deletions(-)
 delete mode 100644 drivers/net/usb/asix.c
 create mode 100644 drivers/net/usb/asix.h
 create mode 100644 drivers/net/usb/asix_common.c
 create mode 100644 drivers/net/usb/asix_devices.c
 create mode 100644 drivers/net/usb/ax88172a.c

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox