Netdev List
 help / color / mirror / Atom feed
* [PATCH 3/9] cxgb4vf: Add new macros and definitions for hardware constants
From: Casey Leedom @ 2010-06-25 22:11 UTC (permalink / raw)
  To: netdev

Add new macros and definitions for hardware constants.

Signed-off-by: Casey Leedom
---
 drivers/net/cxgb4/t4_hw.h   |   39 +++++++++++++++++++++++++++++++++++++++
 drivers/net/cxgb4/t4_regs.h |    3 +++
 2 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/drivers/net/cxgb4/t4_hw.h b/drivers/net/cxgb4/t4_hw.h
index 98c02be..e875d09 100644
--- a/drivers/net/cxgb4/t4_hw.h
+++ b/drivers/net/cxgb4/t4_hw.h
@@ -67,6 +67,45 @@ enum {
 	SGE_MAX_WR_LEN = 512,     /* max WR size in bytes */
 	SGE_NTIMERS = 6,          /* # of interrupt holdoff timer values */
 	SGE_NCOUNTERS = 4,        /* # of interrupt packet counter values */
+
+	SGE_TIMER_RSTRT_CNTR = 6, /* restart RX packet threshold counter */
+	SGE_TIMER_UPD_CIDX = 7,   /* update cidx only */
+
+	SGE_EQ_IDXSIZE = 64,      /* egress queue pidx/cidx unit size */
+
+	SGE_INTRDST_PCI = 0,      /* interrupt destination is PCI-E */
+	SGE_INTRDST_IQ = 1,       /*   destination is an ingress queue */
+
+	SGE_UPDATEDEL_NONE = 0,   /* ingress queue pidx update delivery */
+	SGE_UPDATEDEL_INTR = 1,   /*   interrupt */
+	SGE_UPDATEDEL_STPG = 2,   /*   status page */
+	SGE_UPDATEDEL_BOTH = 3,   /*   interrupt and status page */
+
+	SGE_HOSTFCMODE_NONE = 0,  /* egress queue cidx updates */
+	SGE_HOSTFCMODE_IQ = 1,    /*   sent to ingress queue */
+	SGE_HOSTFCMODE_STPG = 2,  /*   sent to status page */
+	SGE_HOSTFCMODE_BOTH = 3,  /*   ingress queue and status page */
+
+	SGE_FETCHBURSTMIN_16B = 0,/* egress queue descriptor fetch minimum */
+	SGE_FETCHBURSTMIN_32B = 1,
+	SGE_FETCHBURSTMIN_64B = 2,
+	SGE_FETCHBURSTMIN_128B = 3,
+
+	SGE_FETCHBURSTMAX_64B = 0,/* egress queue descriptor fetch maximum */
+	SGE_FETCHBURSTMAX_128B = 1,
+	SGE_FETCHBURSTMAX_256B = 2,
+	SGE_FETCHBURSTMAX_512B = 3,
+
+	SGE_CIDXFLUSHTHRESH_1 = 0,/* egress queue cidx flush threshold */
+	SGE_CIDXFLUSHTHRESH_2 = 1,
+	SGE_CIDXFLUSHTHRESH_4 = 2,
+	SGE_CIDXFLUSHTHRESH_8 = 3,
+	SGE_CIDXFLUSHTHRESH_16 = 4,
+	SGE_CIDXFLUSHTHRESH_32 = 5,
+	SGE_CIDXFLUSHTHRESH_64 = 6,
+	SGE_CIDXFLUSHTHRESH_128 = 7,
+
+	SGE_INGPADBOUNDARY_SHIFT = 5,/* ingress queue pad boundary */
 };
 
 struct sge_qstat {                /* data written to SGE queue status entries 
*/
diff --git a/drivers/net/cxgb4/t4_regs.h b/drivers/net/cxgb4/t4_regs.h
index 8fed46d..bf21c14 100644
--- a/drivers/net/cxgb4/t4_regs.h
+++ b/drivers/net/cxgb4/t4_regs.h
@@ -93,12 +93,15 @@
 #define  PKTSHIFT_MASK          0x00001c00U
 #define  PKTSHIFT_SHIFT         10
 #define  PKTSHIFT(x)            ((x) << PKTSHIFT_SHIFT)
+#define  PKTSHIFT_GET(x)	(((x) & PKTSHIFT_MASK) >> PKTSHIFT_SHIFT)
 #define  INGPCIEBOUNDARY_MASK   0x00000380U
 #define  INGPCIEBOUNDARY_SHIFT  7
 #define  INGPCIEBOUNDARY(x)     ((x) << INGPCIEBOUNDARY_SHIFT)
 #define  INGPADBOUNDARY_MASK    0x00000070U
 #define  INGPADBOUNDARY_SHIFT   4
 #define  INGPADBOUNDARY(x)      ((x) << INGPADBOUNDARY_SHIFT)
+#define  INGPADBOUNDARY_GET(x)	(((x) & INGPADBOUNDARY_MASK) \
+				 >> INGPADBOUNDARY_SHIFT)
 #define  EGRPCIEBOUNDARY_MASK   0x0000000eU
 #define  EGRPCIEBOUNDARY_SHIFT  1
 #define  EGRPCIEBOUNDARY(x)     ((x) << EGRPCIEBOUNDARY_SHIFT)

^ permalink raw reply related

* [PATCH 2/9] cxgb4vf: update to latest T4 firmware API file
From: Casey Leedom @ 2010-06-25 22:10 UTC (permalink / raw)
  To: netdev

Update to latest T4 firmware API file.

Signed-off-by: Casey Leedom
---
 drivers/net/cxgb4/t4_hw.c    |    2 +-
 drivers/net/cxgb4/t4fw_api.h |   27 +++++++++++++++++++++------
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/drivers/net/cxgb4/t4_hw.c b/drivers/net/cxgb4/t4_hw.c
index d92129b..3e63d14 100644
--- a/drivers/net/cxgb4/t4_hw.c
+++ b/drivers/net/cxgb4/t4_hw.c
@@ -2518,7 +2518,7 @@ int t4_cfg_pfvf(struct adapter *adap, unsigned int mbox, 
unsigned int pf,
 	c.retval_len16 = htonl(FW_LEN16(c));
 	c.niqflint_niq = htonl(FW_PFVF_CMD_NIQFLINT(rxqi) |
 			       FW_PFVF_CMD_NIQ(rxq));
-	c.cmask_to_neq = htonl(FW_PFVF_CMD_CMASK(cmask) |
+	c.type_to_neq = htonl(FW_PFVF_CMD_CMASK(cmask) |
 			       FW_PFVF_CMD_PMASK(pmask) |
 			       FW_PFVF_CMD_NEQ(txq));
 	c.tc_to_nexactf = htonl(FW_PFVF_CMD_TC(tc) | FW_PFVF_CMD_NVI(vi) |
diff --git a/drivers/net/cxgb4/t4fw_api.h b/drivers/net/cxgb4/t4fw_api.h
index 111c2a5..ca45df8 100644
--- a/drivers/net/cxgb4/t4fw_api.h
+++ b/drivers/net/cxgb4/t4fw_api.h
@@ -71,6 +71,7 @@ struct fw_wr_hdr {
 #define FW_WR_ATOMIC(x)	 ((x) << 23)
 #define FW_WR_FLUSH(x)   ((x) << 22)
 #define FW_WR_COMPL(x)   ((x) << 21)
+#define FW_WR_IMMDLEN_MASK 0xff
 #define FW_WR_IMMDLEN(x) ((x) << 0)
 
 #define FW_WR_EQUIQ	(1U << 31)
@@ -447,7 +448,9 @@ enum fw_params_param_dev {
 	FW_PARAMS_PARAM_DEV_INTVER_RI	= 0x07,
 	FW_PARAMS_PARAM_DEV_INTVER_ISCSIPDU = 0x08,
 	FW_PARAMS_PARAM_DEV_INTVER_ISCSI = 0x09,
-	FW_PARAMS_PARAM_DEV_INTVER_FCOE = 0x0A
+	FW_PARAMS_PARAM_DEV_INTVER_FCOE = 0x0A,
+	FW_PARAMS_PARAM_DEV_FWREV = 0x0B,
+	FW_PARAMS_PARAM_DEV_TPREV = 0x0C,
 };
 
 /*
@@ -518,7 +521,7 @@ struct fw_pfvf_cmd {
 	__be32 op_to_vfn;
 	__be32 retval_len16;
 	__be32 niqflint_niq;
-	__be32 cmask_to_neq;
+	__be32 type_to_neq;
 	__be32 tc_to_nexactf;
 	__be32 r_caps_to_nethctrl;
 	__be16 nricq;
@@ -535,11 +538,16 @@ struct fw_pfvf_cmd {
 #define FW_PFVF_CMD_NIQ(x) ((x) << 0)
 #define FW_PFVF_CMD_NIQ_GET(x) (((x) >> 0) & 0xfffff)
 
+#define FW_PFVF_CMD_TYPE (1 << 31)
+#define FW_PFVF_CMD_TYPE_GET(x) (((x) >> 31) & 0x1)
+
 #define FW_PFVF_CMD_CMASK(x) ((x) << 24)
-#define FW_PFVF_CMD_CMASK_GET(x) (((x) >> 24) & 0xf)
+#define FW_PFVF_CMD_CMASK_MASK 0xf
+#define FW_PFVF_CMD_CMASK_GET(x) (((x) >> 24) & FW_PFVF_CMD_CMASK_MASK)
 
 #define FW_PFVF_CMD_PMASK(x) ((x) << 20)
-#define FW_PFVF_CMD_PMASK_GET(x) (((x) >> 20) & 0xf)
+#define FW_PFVF_CMD_PMASK_MASK 0xf
+#define FW_PFVF_CMD_PMASK_GET(x) (((x) >> 20) & FW_PFVF_CMD_PMASK_MASK)
 
 #define FW_PFVF_CMD_NEQ(x) ((x) << 0)
 #define FW_PFVF_CMD_NEQ_GET(x) (((x) >> 0) & 0xfffff)
@@ -692,6 +700,7 @@ struct fw_eq_eth_cmd {
 #define FW_EQ_ETH_CMD_EQID(x) ((x) << 0)
 #define FW_EQ_ETH_CMD_EQID_GET(x) (((x) >> 0) & 0xfffff)
 #define FW_EQ_ETH_CMD_PHYSEQID(x) ((x) << 0)
+#define FW_EQ_ETH_CMD_PHYSEQID_GET(x) (((x) >> 0) & 0xfffff)
 
 #define FW_EQ_ETH_CMD_FETCHSZM(x) ((x) << 26)
 #define FW_EQ_ETH_CMD_STATUSPGNS(x) ((x) << 25)
@@ -832,12 +841,14 @@ struct fw_vi_cmd {
 #define FW_VI_CMD_VIID(x) ((x) << 0)
 #define FW_VI_CMD_VIID_GET(x) ((x) & 0xfff)
 #define FW_VI_CMD_PORTID(x) ((x) << 4)
+#define FW_VI_CMD_PORTID_GET(x) (((x) >> 4) & 0xf)
 #define FW_VI_CMD_RSSSIZE_GET(x) (((x) >> 0) & 0x7ff)
 
 /* Special VI_MAC command index ids */
 #define FW_VI_MAC_ADD_MAC		0x3FF
 #define FW_VI_MAC_ADD_PERSIST_MAC	0x3FE
 #define FW_VI_MAC_MAC_BASED_FREE	0x3FD
+#define FW_CLS_TCAM_NUM_ENTRIES		336
 
 enum fw_vi_mac_smac {
 	FW_VI_MAC_MPS_TCAM_ENTRY,
@@ -888,6 +899,7 @@ struct fw_vi_rxmode_cmd {
 };
 
 #define FW_VI_RXMODE_CMD_VIID(x) ((x) << 0)
+#define FW_VI_RXMODE_CMD_MTU_MASK 0xffff
 #define FW_VI_RXMODE_CMD_MTU(x) ((x) << 16)
 #define FW_VI_RXMODE_CMD_PROMISCEN_MASK 0x3
 #define FW_VI_RXMODE_CMD_PROMISCEN(x) ((x) << 14)
@@ -1173,6 +1185,7 @@ struct fw_port_cmd {
 #define FW_PORT_CMD_PORTID_GET(x) (((x) >> 0) & 0xf)
 
 #define FW_PORT_CMD_ACTION(x) ((x) << 16)
+#define FW_PORT_CMD_ACTION_GET(x) (((x) >> 16) & 0xffff)
 
 #define FW_PORT_CMD_CTLBF(x) ((x) << 10)
 #define FW_PORT_CMD_OVLAN3(x) ((x) << 7)
@@ -1487,6 +1500,7 @@ struct fw_rss_glb_config_cmd {
 };
 
 #define FW_RSS_GLB_CONFIG_CMD_MODE(x)	((x) << 28)
+#define FW_RSS_GLB_CONFIG_CMD_MODE_GET(x) (((x) >> 28) & 0xf)
 
 #define FW_RSS_GLB_CONFIG_CMD_MODE_MANUAL	0
 #define FW_RSS_GLB_CONFIG_CMD_MODE_BASICVIRTUAL	1
@@ -1503,13 +1517,14 @@ struct fw_rss_vi_config_cmd {
 		} manual;
 		struct fw_rss_vi_config_basicvirtual {
 			__be32 r6;
-			__be32 defaultq_to_ip4udpen;
+			__be32 defaultq_to_udpen;
 #define FW_RSS_VI_CONFIG_CMD_DEFAULTQ(x)  ((x) << 16)
+#define FW_RSS_VI_CONFIG_CMD_DEFAULTQ_GET(x) (((x) >> 16) & 0x3ff)
 #define FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN (1U << 4)
 #define FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN  (1U << 3)
 #define FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN (1U << 2)
 #define FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN  (1U << 1)
-#define FW_RSS_VI_CONFIG_CMD_IP4UDPEN     (1U << 0)
+#define FW_RSS_VI_CONFIG_CMD_UDPEN        (1U << 0)
 			__be64 r9;
 			__be64 r10;
 		} basicvirtual;

^ permalink raw reply related

* [PATCH 1/9] cxgb4vf: small changes to message processing structures/macros
From: Casey Leedom @ 2010-06-25 22:09 UTC (permalink / raw)
  To: netdev

Split cpl_tx_pkt_lso into core message structure and encapsulated message,
make RSPD_LEN macro match other response descriptor macros.

Signed-off-by: Casey Leedom
---
 drivers/net/cxgb4/sge.c    |    4 ++--
 drivers/net/cxgb4/t4_hw.h  |    4 +++-
 drivers/net/cxgb4/t4_msg.h |   14 ++++++++++++--
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/net/cxgb4/sge.c b/drivers/net/cxgb4/sge.c
index d1f8f22..4388f72 100644
--- a/drivers/net/cxgb4/sge.c
+++ b/drivers/net/cxgb4/sge.c
@@ -931,7 +931,7 @@ out_free:	dev_kfree_skb(skb);
 
 	ssi = skb_shinfo(skb);
 	if (ssi->gso_size) {
-		struct cpl_tx_pkt_lso *lso = (void *)wr;
+		struct cpl_tx_pkt_lso_core *lso = (void *)(wr + 1);
 		bool v6 = (ssi->gso_type & SKB_GSO_TCPV6) != 0;
 		int l3hdr_len = skb_network_header_len(skb);
 		int eth_xtra_len = skb_network_offset(skb) - ETH_HLEN;
@@ -1718,7 +1718,7 @@ static int process_responses(struct sge_rspq *q, int 
budget)
 					free_rx_bufs(q->adap, &rxq->fl, 1);
 					q->offset = 0;
 				}
-				len &= RSPD_LEN;
+				len = RSPD_LEN(len);
 			}
 			si.tot_len = len;
 
diff --git a/drivers/net/cxgb4/t4_hw.h b/drivers/net/cxgb4/t4_hw.h
index f886677..98c02be 100644
--- a/drivers/net/cxgb4/t4_hw.h
+++ b/drivers/net/cxgb4/t4_hw.h
@@ -88,11 +88,13 @@ struct rsp_ctrl {
 };
 
 #define RSPD_NEWBUF 0x80000000U
-#define RSPD_LEN    0x7fffffffU
+#define RSPD_LEN(x) (((x) >> 0) & 0x7fffffffU)
+#define RSPD_QID(x) RSPD_LEN(x)
 
 #define RSPD_GEN(x)  ((x) >> 7)
 #define RSPD_TYPE(x) (((x) >> 4) & 3)
 
 #define QINTR_CNT_EN       0x1
 #define QINTR_TIMER_IDX(x) ((x) << 1)
+#define QINTR_TIMER_IDX_GET(x) (((x) << 1) & 0x7)
 #endif /* __T4_HW_H */
diff --git a/drivers/net/cxgb4/t4_msg.h b/drivers/net/cxgb4/t4_msg.h
index 7a981b8..623932b 100644
--- a/drivers/net/cxgb4/t4_msg.h
+++ b/drivers/net/cxgb4/t4_msg.h
@@ -443,8 +443,7 @@ struct cpl_tx_pkt {
 
 #define cpl_tx_pkt_xt cpl_tx_pkt
 
-struct cpl_tx_pkt_lso {
-	WR_HDR;
+struct cpl_tx_pkt_lso_core {
 	__be32 lso_ctrl;
 #define LSO_TCPHDR_LEN(x) ((x) << 0)
 #define LSO_IPHDR_LEN(x)  ((x) << 4)
@@ -460,6 +459,12 @@ struct cpl_tx_pkt_lso {
 	/* encapsulated CPL (TX_PKT, TX_PKT_XT or TX_DATA) follows here */
 };
 
+struct cpl_tx_pkt_lso {
+	WR_HDR;
+	struct cpl_tx_pkt_lso_core c;
+	/* encapsulated CPL (TX_PKT, TX_PKT_XT or TX_DATA) follows here */
+};
+
 struct cpl_iscsi_hdr {
 	union opcode_tid ot;
 	__be16 pdu_len_ddp;
@@ -623,6 +628,11 @@ struct cpl_fw6_msg {
 	__be64 data[4];
 };
 
+/* cpl_fw6_msg.type values */
+enum {
+	FW6_TYPE_CMD_RPL = 0,
+};
+
 enum {
 	ULP_TX_MEM_READ = 2,
 	ULP_TX_MEM_WRITE = 3,

^ permalink raw reply related

* [PATCH 0/9] New cxgb4vf network driver for Chelsio T4 Virtual Function NIC
From: Casey Leedom @ 2010-06-25 22:07 UTC (permalink / raw)
  To: netdev

This patch series introduces a new network driver for the Chelsio T4 PCI-E
SR-IOV Virtual Function NIC.  The patches are against net-next as of commit
39c9cf07077146b14ab077a0e27c869c6f0e6199.

This driver "depends" on the cxgb4 NIC driver only in-so-far as the cxgb4
driver needs to "provision" chip resources for each of the Virtual Functions
and the cxgb4 driver must enable the PCI-E SR-IOV functionality.  After that
the new "cxgb4vf" driver operates completely independently.  (It will often
be the case that the cxgb4vf driver will be operating withing a Virtual
Machine via "PCI Pass Through."

This is my first submission to Linux so I apologize in advance for any
mistakes.  I looked at many submissions to see how to do this but I
anticipate that I've almost certainly missed something critical.  Please
correct me on anything I've done wrong and I will happily fix them.  Thanks
in advance for you patience and understanding.

There is one part of this submission where I needed to make a big guess
regarding driver policies and procedures so I'll draw your attention to
that.  There are several header files which both the cxgb4 and cxgb4vf
drivers need to operate (T4 hardware register definitions, message
structures, etc.)  This patch series leaves those files in place within the
cxgb4 driver directory (with a few tiny modifications to add new
definitions) and the cxgb4vf driver includes them via "../cxgb4/xxx.h" I
found a couple of similar usages but I couldn't determine what the official
policy was.

Again, thank you for your time and consideration.

Casey Leedom

 drivers/net/Kconfig                |   23 +
 drivers/net/Makefile               |    1 +
 drivers/net/cxgb4/cxgb4_main.c     |  106 ++
 drivers/net/cxgb4/t4_hw.c          |    2 +-
 drivers/net/cxgb4/t4_hw.h          |   39 +
 drivers/net/cxgb4/t4_regs.h        |    3 +
 drivers/net/cxgb4/t4fw_api.h       |   27 +-
 drivers/net/cxgb4vf/Makefile       |    7 +
 drivers/net/cxgb4vf/adapter.h      |  540 +++++++
 drivers/net/cxgb4vf/cxgb4vf_main.c | 2906 ++++++++++++++++++++++++++++++++++++
 drivers/net/cxgb4vf/sge.c          | 2460 ++++++++++++++++++++++++++++++
 drivers/net/cxgb4vf/t4vf_common.h  |  273 ++++
 drivers/net/cxgb4vf/t4vf_defs.h    |  121 ++
 drivers/net/cxgb4vf/t4vf_hw.c      | 1333 +++++++++++++++++
 14 files changed, 7834 insertions(+), 7 deletions(-)

^ permalink raw reply

* Re: [RFC PATCH v2 4/5] skb: add tracepoints to freeing skb
From: Eric Dumazet @ 2010-06-25 20:05 UTC (permalink / raw)
  To: Koki Sanagi; +Cc: linux-kernel, kaneshige.kenji, izumi.taku, netdev
In-Reply-To: <4C2456DA.8030200@jp.fujitsu.com>

Le vendredi 25 juin 2010 à 16:12 +0900, Koki Sanagi a écrit :

> > You might add a trace point to skb_free_datagram_locked() too, since it
> > contains an inlined consume_skb()
> > 
> 
> I think it is contrary.

I think you are _very_ wrong.

> skb_free_datagram_locked() contains consume_skb(), so tracepoint isn't needed.
> Because skb_free_datagram_locked() can be traced by trace_consume_skb().
> 
> 
> 

Koki, it would be good if you worked on net-next-2.6, so that my comment
applies.

Also, not sending this kind of patches on netdev is not going to help
very much.

Who is supposed to review them on lkml and Ack them ? 

Nobody.

Please build your future network related patches against net-next-2.6,
and send them to nedev and David Miller, the official network
maintainer, as stated in MAINTAINERS file.

NETWORKING [GENERAL]
M:      "David S. Miller" <davem@davemloft.net>
L:      netdev@vger.kernel.org
W:      http://www.linuxfoundation.org/en/Net
W:      http://patchwork.ozlabs.org/project/netdev/list/
T:      git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.git
T:      git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6.git
S:      Maintained
F:      net/
F:      include/net/
F:      include/linux/in.h
F:      include/linux/net.h
F:      include/linux/netdevice.h

^ permalink raw reply

* [PATCH 2.6.35] bonding: prevent netpoll over bonded interfaces
From: Andy Gospodarek @ 2010-06-25 19:50 UTC (permalink / raw)
  To: netdev, amwang, fubar


Support for netpoll over bonded interfaces was added here:

	commit f6dc31a85cd46a959bdd987adad14c3b645e03c1
	Author: WANG Cong <amwang@redhat.com>
	Date:   Thu May 6 00:48:51 2010 -0700

	    bonding: make bonding support netpoll

but it is bad enough that we should probably just disable netpoll over
bonding until some of the locking logic in the bonding driver is changed
or converted completely to RCU.  Simple actions like changing the active
slave in active-backup mode will hang the box if a high enough printk
debugging level is enabled.

Keeping the old code around will be good for anyone that wants to work
on it (and for after the RCU conversion), so I propose this small patch
rather than ripping it all out.

Signed-off-by: Andy Gospodarek <andy@greyhouse.net>

---
 drivers/net/bonding/bond_main.c |   33 ++++++++++++++++++++++-----------
 1 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 5e12462..c3d98dd 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -168,7 +168,7 @@ static int arp_ip_count;
 static int bond_mode	= BOND_MODE_ROUNDROBIN;
 static int xmit_hashtype = BOND_XMIT_POLICY_LAYER2;
 static int lacp_fast;
-
+static int disable_netpoll = 1;
 
 const struct bond_parm_tbl bond_lacp_tbl[] = {
 {	"slow",		AD_LACP_SLOW},
@@ -1742,15 +1742,23 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
 	bond_set_carrier(bond);
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
-	if (slaves_support_netpoll(bond_dev)) {
-		bond_dev->priv_flags &= ~IFF_DISABLE_NETPOLL;
-		if (bond_dev->npinfo)
-			slave_dev->npinfo = bond_dev->npinfo;
-	} else if (!(bond_dev->priv_flags & IFF_DISABLE_NETPOLL)) {
+	/*
+	 * Netpoll and bonding is broken, make sure it is not initialized
+	 * until it is fixed.
+	 */
+	if (disable_netpoll) {
 		bond_dev->priv_flags |= IFF_DISABLE_NETPOLL;
-		pr_info("New slave device %s does not support netpoll\n",
-			slave_dev->name);
-		pr_info("Disabling netpoll support for %s\n", bond_dev->name);
+	} else {
+		if (slaves_support_netpoll(bond_dev)) {
+			bond_dev->priv_flags &= ~IFF_DISABLE_NETPOLL;
+			if (bond_dev->npinfo)
+				slave_dev->npinfo = bond_dev->npinfo;
+		} else if (!(bond_dev->priv_flags & IFF_DISABLE_NETPOLL)) {
+			bond_dev->priv_flags |= IFF_DISABLE_NETPOLL;
+			pr_info("New slave device %s does not support netpoll\n",
+				slave_dev->name);
+			pr_info("Disabling netpoll support for %s\n", bond_dev->name);
+		}
 	}
 #endif
 	read_unlock(&bond->lock);
@@ -1950,8 +1958,11 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
 	read_lock_bh(&bond->lock);
-	if (slaves_support_netpoll(bond_dev))
-		bond_dev->priv_flags &= ~IFF_DISABLE_NETPOLL;
+
+	 /* Make sure netpoll over stays disabled until fixed. */
+	if (!disable_netpoll)
+		if (slaves_support_netpoll(bond_dev))
+				bond_dev->priv_flags &= ~IFF_DISABLE_NETPOLL;
 	read_unlock_bh(&bond->lock);
 	if (slave_dev->netdev_ops->ndo_netpoll_cleanup)
 		slave_dev->netdev_ops->ndo_netpoll_cleanup(slave_dev);

^ permalink raw reply related

* Re: nonlocal_bind & IPv6
From: Michal Humpula @ 2010-06-25 19:10 UTC (permalink / raw)
  To: Rémi Denis-Courmont; +Cc: netdev
In-Reply-To: <30fe1fa984e52f4cca318e54f9d97a21@chewa.net>

Ok, more detail example. 

Let on each node be an apache (just for an example), and you configure VirtualHost for 
specific IP. So when node A fails, keepalived move IP to the node B and everything is 
still running. No need for restart of apache or anything else. There is a probably a 
better solution, but I can't find anything more simple than the posted patch:)

On Friday 25 of June 2010 20:59:58 Rémi Denis-Courmont wrote:
> On Fri, 25 Jun 2010 20:43:45 +0200, Michal Humpula
> 
> <michal.humpula@hudrydum.cz> wrote:
> > I was just wondering, what's wrong with this?
> 
> It's not in unified format :D
> 
> > *** linux-2.6.34/net/ipv6/af_inet6.c    2010-05-16 23:17:36.000000000
> > +0200
> > --- linux-2.6.34-hack/net/ipv6/af_inet6.c       2010-06-25
> > 19:50:19.000000000 +0200
> > ***************
> > *** 345,354 ****
> > --- 345,356 ----
> > 
> >                         if (!(addr_type & IPV6_ADDR_MULTICAST)) {
> >                         
> >                                 if (!ipv6_chk_addr(net, &addr->sin6_addr,
> >                                 
> >                                                    dev, 0)) {
> > 
> > +           if (!sysctl_ip_nonlocal_bind) {
> > 
> >                                         err = -EADDRNOTAVAIL;
> >                                         goto out_unlock;
> >             
> >             }
> >             
> >                                 }
> > 
> > +                       }
> > 
> >                         rcu_read_unlock();
> >                 
> >                 }
> >         
> >         }
> > 
> > Motivation: just want to balance one IPv6 address between two nodes with
> > the help of keepalived the same way I do it with IPv4 without the need
> > of restarting the daemons binding on that IP.
> 
> nonlocal_bind seems a bit 80's to me. Why don't you bind the daemon to
> [::]? If it needs to know its own address, it can always use getsockname()
> for connected sockets and IPV6_PKTINFO ancillary data for datagram sockets.

^ permalink raw reply

* Re: nonlocal_bind & IPv6
From: Rémi Denis-Courmont @ 2010-06-25 18:59 UTC (permalink / raw)
  To: Michal Humpula; +Cc: netdev
In-Reply-To: <201006252043.45581.michal.humpula@hudrydum.cz>


On Fri, 25 Jun 2010 20:43:45 +0200, Michal Humpula
<michal.humpula@hudrydum.cz> wrote:
> I was just wondering, what's wrong with this?

It's not in unified format :D

> *** linux-2.6.34/net/ipv6/af_inet6.c    2010-05-16 23:17:36.000000000
> +0200
> --- linux-2.6.34-hack/net/ipv6/af_inet6.c       2010-06-25
> 19:50:19.000000000 +0200
> ***************
> *** 345,354 ****
> --- 345,356 ----
>                         if (!(addr_type & IPV6_ADDR_MULTICAST)) {
>                                 if (!ipv6_chk_addr(net, &addr->sin6_addr,
>                                                    dev, 0)) {
> +           if (!sysctl_ip_nonlocal_bind) {
>                                         err = -EADDRNOTAVAIL;
>                                         goto out_unlock;
>             }
>                                 }
> +                       }
>                         rcu_read_unlock();
>                 }
>         }
> 
> Motivation: just want to balance one IPv6 address between two nodes with
> the help of keepalived the same way I do it with IPv4 without the need
> of restarting the daemons binding on that IP.

nonlocal_bind seems a bit 80's to me. Why don't you bind the daemon to
[::]? If it needs to know its own address, it can always use getsockname()
for connected sockets and IPV6_PKTINFO ancillary data for datagram sockets.

-- 
Rémi Denis-Courmont
http://www.remlab.net
http://fi.linkedin.com/in/remidenis


^ permalink raw reply

* nonlocal_bind & IPv6
From: Michal Humpula @ 2010-06-25 18:43 UTC (permalink / raw)
  To: netdev

Hi, 

I was just wondering, what's wrong with this?

*** linux-2.6.34/net/ipv6/af_inet6.c    2010-05-16 23:17:36.000000000 +0200
--- linux-2.6.34-hack/net/ipv6/af_inet6.c       2010-06-25 19:50:19.000000000 +0200
***************
*** 345,354 ****
--- 345,356 ----
                        if (!(addr_type & IPV6_ADDR_MULTICAST)) {
                                if (!ipv6_chk_addr(net, &addr->sin6_addr,
                                                   dev, 0)) {
+           if (!sysctl_ip_nonlocal_bind) {
                                        err = -EADDRNOTAVAIL;
                                        goto out_unlock;
            }
                                }
+                       }
                        rcu_read_unlock();
                }
        }

Motivation: just want to balance one IPv6 address between two nodes with the help of 
keepalived the same way I do it with IPv4 without the need of restarting the daemons 
binding on that IP.

Regards

Michal Humpula

^ permalink raw reply

* LPC track "User visible challenges in Networking" - topics wanted
From: Matt Domsch @ 2010-06-25 18:27 UTC (permalink / raw)
  To: netdev

Greetings.  I've been asked to organize a track for the Linux Plumbers
Conference [1], November 3-5, 2010 in Cambridge, MA.  As I'm still
pursuing my "Deterministic Network Device Naming" problem, that's one
topic for the track.  Dan Williams of NetworkManager fame has agreed
to submit a topic.

I'm actively soliciting more ideas for presentation and conversation
to fill a ~2.5 hour mini-conference.

If you have a challenge that you think would benefit from discussion
at the Plumbers Conference, please add your idea to the wiki [2], and
drop me a note.

Thanks,
Matt


[1] http://www.linuxplumbersconf.org/2010/
[2] http://wiki.linuxplumbersconf.org/2010:topics

-- 
Matt Domsch
Technology Strategist
Dell | Office of the CTO

^ permalink raw reply

* Re: linux-next: manual merge of the net tree with the net-current tree
From: David Miller @ 2010-06-25 18:22 UTC (permalink / raw)
  To: sfr; +Cc: netdev, linux-next, linux-kernel, herbert, xiaosuo, eric.dumazet
In-Reply-To: <20100623125116.1370bdd4.sfr@canb.auug.org.au>

From: Stephen Rothwell <sfr@canb.auug.org.au>
Date: Wed, 23 Jun 2010 12:51:16 +1000

> Hi all,
> 
> Today's linux-next merge of the net tree got a conflict in
> net/ipv4/ip_output.c between commit
> 26cde9f7e2747b6d254b704594eed87ab959afa5 ("udp: Fix bogus UFO packet
> generation") from the net-current tree and commit
> d8d1f30b95a635dbd610dcc5eb641aca8f4768cf ("net-next: remove useless union
> keyword") from the net tree.
> 
> Just context changes. I fixed it up (see below) and can carry the fix as
> necessary.

I recently merged net-2.6 into net-next-2.6, let me know if the problem
persists.

^ permalink raw reply

* Re: dhclient, checksum and tap
From: David Miller @ 2010-06-25 18:21 UTC (permalink / raw)
  To: mst; +Cc: herbert.xu, netdev
In-Reply-To: <20100625151008.GA17911@redhat.com>

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Fri, 25 Jun 2010 18:10:08 +0300

> I've been looking at the issue of checksum on
> dhcp packets: to recap, 8dc4194474159660d7f37c495e3fc3f10d0db8cc
> added a way for af_packet sockets to get the packet status.
> Unfortunately not all dhcp clients caught up with
> this development, so they are still broken
> when both server and client run on the same host,
> e.g. with bridge+tap.
> 
> And of course virtualization adds another way to run
> old dhcp clients, so userspace virtio net in qemu has
> a hack to detect DHCP and fill in the checksum.
> I guess we could add this in vhost, as well.
> 
> However, one wonders whether the tap driver is a better place
> for this work-around, that would help all users.
> Any objections against putting such code in tap?

We added the af_packet status as the migration path to deal with
this issue in the cleanest manner possible.  Putting a new hack
into the TAP driver works contrary to that goal.

^ permalink raw reply

* Re: [PATCH] smsc95xx: Add module parameter to override MAC address
From: David Miller @ 2010-06-25 18:17 UTC (permalink / raw)
  To: s-jan; +Cc: Steve.Glendinning, horms, linux-omap, netdev, Ian.Saturley
In-Reply-To: <4C24BB34.3010601@ti.com>

From: Sebastien Jan <s-jan@ti.com>
Date: Fri, 25 Jun 2010 16:20:36 +0200

> Hi Steve,
> 
> Thanks for your answer.
> 
> On 06/25/2010 10:43 AM, Steve.Glendinning@smsc.com wrote:
> [...]
>> I can see you have a different use case, but I don't think this specific
>> driver is the place for this logic.  I'd rather see it added to either
>> the usbnet framework or (preferably) the netdev framework so *all*
>> ethernet drivers can do this the same way.  otherwise we could end up
>> with slight variations of this code in every single driver!
> 
> I perfectly understand your concerns. Unfortunately, I will probably not be
> able to implement these changes into the netdev framework. However, I'd be 
> happy to make some tests if someone proposes such changes.

I don't think such logic belongs anywhere other than an initrd.

We have mechanisms by which to handle this already, and contrary to
what many people claim it is not at all so hard to create a custom
initrd.

^ permalink raw reply

* Re: SO_REUSEPORT
From: Tom Herbert @ 2010-06-25 17:39 UTC (permalink / raw)
  To: Brian Bloniarz; +Cc: Alexander Clouter, linux-kernel, netdev
In-Reply-To: <4C2231B5.10401@athenacr.com>

>> Of course this depends on what you are doing, but my opinion is that the
>> functionality has been unneeded so far by people in the kernel, so *I*
>> must be doing something wrong ;)
>
> Tom Herbert gave a pretty great description of why you
> might want this functionality in his original patch submission:
>
> http://kerneltrap.org/mailarchive/linux-netdev/2010/4/19/6274993
>
> If you follow that thread though, there wasn't consensus about
> the best architecture & API for it, and nothing has made it
> yet.
>
I am planning to get back to this as the patch still needs some work
and isn't quite robust or optimized yet.  Some restructuring is needed
in the socket hash lists.  The UDP implementation in the patch will
work okay, and the TCP works as long as the number of listeners isn't
changing.

^ permalink raw reply

* Re: [PATCH ethtool 4/5] ethtool: Implement named message type flags
From: Jeff Garzik @ 2010-06-25 17:11 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: netdev, linux-net-drivers
In-Reply-To: <1277477385.2094.9.camel@achroite.uk.solarflarecom.com>

On 06/25/2010 10:49 AM, Ben Hutchings wrote:
> +static struct cmdline_info cmdline_msglvl[] = {
> +	{ "drv", CMDL_FLAG,&msglvl_wanted, NULL,
> +	  NETIF_MSG_DRV,&msglvl_unwanted },
> +	{ "probe", CMDL_FLAG,&msglvl_wanted, NULL,
> +	  NETIF_MSG_PROBE,&msglvl_unwanted },
> +	{ "link", CMDL_FLAG,&msglvl_wanted, NULL,
> +	  NETIF_MSG_LINK,&msglvl_unwanted },
> +	{ "timer", CMDL_FLAG,&msglvl_wanted, NULL,
> +	  NETIF_MSG_TIMER,&msglvl_unwanted },
> +	{ "ifdown", CMDL_FLAG,&msglvl_wanted, NULL,
> +	  NETIF_MSG_IFDOWN,&msglvl_unwanted },
> +	{ "ifup", CMDL_FLAG,&msglvl_wanted, NULL,
> +	  NETIF_MSG_IFUP,&msglvl_unwanted },
> +	{ "rx_err", CMDL_FLAG,&msglvl_wanted, NULL,
> +	  NETIF_MSG_RX_ERR,&msglvl_unwanted },
> +	{ "tx_err", CMDL_FLAG,&msglvl_wanted, NULL,
> +	  NETIF_MSG_TX_ERR,&msglvl_unwanted },
> +	{ "tx_queued", CMDL_FLAG,&msglvl_wanted, NULL,
> +	  NETIF_MSG_TX_QUEUED,&msglvl_unwanted },
> +	{ "intr", CMDL_FLAG,&msglvl_wanted, NULL,
> +	  NETIF_MSG_INTR,&msglvl_unwanted },
> +	{ "tx_done", CMDL_FLAG,&msglvl_wanted, NULL,
> +	  NETIF_MSG_TX_DONE,&msglvl_unwanted },
> +	{ "rx_status", CMDL_FLAG,&msglvl_wanted, NULL,
> +	  NETIF_MSG_RX_STATUS,&msglvl_unwanted },
> +	{ "pktdata", CMDL_FLAG,&msglvl_wanted, NULL,
> +	  NETIF_MSG_PKTDATA,&msglvl_unwanted },
> +	{ "hw", CMDL_FLAG,&msglvl_wanted, NULL,
> +	  NETIF_MSG_HW,&msglvl_unwanted },
> +	{ "wol", CMDL_FLAG,&msglvl_wanted, NULL,
> +	  NETIF_MSG_WOL,&msglvl_unwanted },


A nice improvement over one-variable-per-bit, I think.

applied patches 1-5, thanks!

	Jeff



P.S.  If you could use my open source email address (jgarzik@pobox.com 
or jeff@garzik.org), that would be greatly appreciated.  @redhat.com is 
only used for sign-offs, as it's less portable than !@redhat.com addresses.


^ permalink raw reply

* [PATCH net-next-2.6 4/4] sfc: Log clearer error messages for hardware monitor
From: Ben Hutchings @ 2010-06-25 17:06 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-net-drivers, Jesper Dangaard Brouer
In-Reply-To: <1277485434.2094.13.camel@achroite.uk.solarflarecom.com>

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
 drivers/net/sfc/falcon_boards.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/sfc/falcon_boards.c b/drivers/net/sfc/falcon_boards.c
index 92b35e3..3d950c2 100644
--- a/drivers/net/sfc/falcon_boards.c
+++ b/drivers/net/sfc/falcon_boards.c
@@ -108,10 +108,15 @@ static int efx_check_lm87(struct efx_nic *efx, unsigned mask)
 	if (alarms1 || alarms2) {
 		netif_err(efx, hw, efx->net_dev,
 			  "LM87 detected a hardware failure (status %02x:%02x)"
-			  "%s%s\n",
+			  "%s%s%s\n",
 			  alarms1, alarms2,
-			  (alarms1 & LM87_ALARM_TEMP_INT) ? " INTERNAL" : "",
-			  (alarms1 & LM87_ALARM_TEMP_EXT1) ? " EXTERNAL" : "");
+			  (alarms1 & LM87_ALARM_TEMP_INT) ?
+			  "; board is overheating" : "",
+			  (alarms1 & LM87_ALARM_TEMP_EXT1) ?
+			  "; controller is overheating" : "",
+			  (alarms1 & ~(LM87_ALARM_TEMP_INT | LM87_ALARM_TEMP_EXT1)
+			   || alarms2) ?
+			  "; electrical fault" : "");
 		return -ERANGE;
 	}
 
-- 
1.6.2.5

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
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 related

* [PATCH net-next-2.6 3/4] sfc: Use Toeplitz IPv4 hash for RSS and hash insertion
From: Ben Hutchings @ 2010-06-25 17:05 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-net-drivers
In-Reply-To: <1277485434.2094.13.camel@achroite.uk.solarflarecom.com>

Insertion of the Falcon hash is unreliable.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
 drivers/net/sfc/falcon.c |   14 ++++++++++++--
 drivers/net/sfc/siena.c  |   11 ++++++++++-
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
index 5a40145..4f9d33f 100644
--- a/drivers/net/sfc/falcon.c
+++ b/drivers/net/sfc/falcon.c
@@ -1581,8 +1581,14 @@ static void falcon_init_rx_cfg(struct efx_nic *efx)
 		EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_XOFF_MAC_TH, data_xoff_thr);
 		EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_XON_TX_TH, ctrl_xon_thr);
 		EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_XOFF_TX_TH, ctrl_xoff_thr);
-		EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_HASH_INSRT_HDR, 1);
 		EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_INGR_EN, 1);
+
+		/* Enable hash insertion. This is broken for the
+		 * 'Falcon' hash so also select Toeplitz TCP/IPv4 and
+		 * IPv4 hashes. */
+		EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_HASH_INSRT_HDR, 1);
+		EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_HASH_ALG, 1);
+		EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_IP_HASH, 1);
 	}
 	/* Always enable XOFF signal from RX FIFO.  We enable
 	 * or disable transmission of pause frames at the MAC. */
@@ -1656,8 +1662,12 @@ static int falcon_init_nic(struct efx_nic *efx)
 
 	falcon_init_rx_cfg(efx);
 
-	/* Set destination of both TX and RX Flush events */
 	if (efx_nic_rev(efx) >= EFX_REV_FALCON_B0) {
+		/* Set hash key for IPv4 */
+		memcpy(&temp, efx->rx_hash_key, sizeof(temp));
+		efx_writeo(efx, &temp, FR_BZ_RX_RSS_TKEY);
+
+		/* Set destination of both TX and RX Flush events */
 		EFX_POPULATE_OWORD_1(temp, FRF_BZ_FLS_EVQ_ID, 0);
 		efx_writeo(efx, &temp, FR_BZ_DP_CTRL);
 	}
diff --git a/drivers/net/sfc/siena.c b/drivers/net/sfc/siena.c
index 7fd258c..3fab030 100644
--- a/drivers/net/sfc/siena.c
+++ b/drivers/net/sfc/siena.c
@@ -327,10 +327,19 @@ static int siena_init_nic(struct efx_nic *efx)
 
 	efx_reado(efx, &temp, FR_AZ_RX_CFG);
 	EFX_SET_OWORD_FIELD(temp, FRF_BZ_RX_DESC_PUSH_EN, 0);
-	EFX_SET_OWORD_FIELD(temp, FRF_BZ_RX_HASH_INSRT_HDR, 1);
 	EFX_SET_OWORD_FIELD(temp, FRF_BZ_RX_INGR_EN, 1);
+	/* Enable hash insertion. This is broken for the 'Falcon' hash
+	 * if IPv6 hashing is also enabled, so also select Toeplitz
+	 * TCP/IPv4 and IPv4 hashes. */
+	EFX_SET_OWORD_FIELD(temp, FRF_BZ_RX_HASH_INSRT_HDR, 1);
+	EFX_SET_OWORD_FIELD(temp, FRF_BZ_RX_HASH_ALG, 1);
+	EFX_SET_OWORD_FIELD(temp, FRF_BZ_RX_IP_HASH, 1);
 	efx_writeo(efx, &temp, FR_AZ_RX_CFG);
 
+	/* Set hash key for IPv4 */
+	memcpy(&temp, efx->rx_hash_key, sizeof(temp));
+	efx_writeo(efx, &temp, FR_BZ_RX_RSS_TKEY);
+
 	/* Enable IPv6 RSS */
 	BUILD_BUG_ON(sizeof(efx->rx_hash_key) <
 		     2 * sizeof(temp) + FRF_CZ_RX_RSS_IPV6_TKEY_HI_WIDTH / 8 ||
-- 
1.6.2.5


-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
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 related

* [PATCH net-next-2.6 2/4] sfc: Move siena_nic_data::ipv6_rss_key to efx_nic::rx_hash_key
From: Ben Hutchings @ 2010-06-25 17:05 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-net-drivers
In-Reply-To: <1277485434.2094.13.camel@achroite.uk.solarflarecom.com>

We will use this hash key for Toeplitz IPv4 hashing too.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
 drivers/net/sfc/efx.c        |    3 +++
 drivers/net/sfc/net_driver.h |    1 +
 drivers/net/sfc/nic.h        |    1 -
 drivers/net/sfc/siena.c      |   12 ++++--------
 4 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index d68f061..2a90bf9 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -1134,6 +1134,9 @@ static int efx_probe_nic(struct efx_nic *efx)
 	 * in MSI-X interrupts. */
 	efx_probe_interrupts(efx);
 
+	if (efx->n_channels > 1)
+		get_random_bytes(&efx->rx_hash_key, sizeof(efx->rx_hash_key));
+
 	efx_set_channels(efx);
 	efx->net_dev->real_num_tx_queues = efx->n_tx_channels;
 
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h
index 8b17c92..ba272a4 100644
--- a/drivers/net/sfc/net_driver.h
+++ b/drivers/net/sfc/net_driver.h
@@ -733,6 +733,7 @@ struct efx_nic {
 	unsigned n_tx_channels;
 	unsigned int rx_buffer_len;
 	unsigned int rx_buffer_order;
+	u8 rx_hash_key[40];
 
 	unsigned int_error_count;
 	unsigned long int_error_expire;
diff --git a/drivers/net/sfc/nic.h b/drivers/net/sfc/nic.h
index 534461f..a39822d 100644
--- a/drivers/net/sfc/nic.h
+++ b/drivers/net/sfc/nic.h
@@ -142,7 +142,6 @@ struct siena_nic_data {
 	u32 fw_build;
 	struct efx_mcdi_iface mcdi;
 	int wol_filter_id;
-	u8 ipv6_rss_key[40];
 };
 
 extern void siena_print_fwver(struct efx_nic *efx, char *buf, size_t len);
diff --git a/drivers/net/sfc/siena.c b/drivers/net/sfc/siena.c
index f1741b4..7fd258c 100644
--- a/drivers/net/sfc/siena.c
+++ b/drivers/net/sfc/siena.c
@@ -285,9 +285,6 @@ static int siena_probe_nic(struct efx_nic *efx)
 		goto fail5;
 	}
 
-	get_random_bytes(&nic_data->ipv6_rss_key,
-			 sizeof(nic_data->ipv6_rss_key));
-
 	return 0;
 
 fail5:
@@ -307,7 +304,6 @@ fail1:
  */
 static int siena_init_nic(struct efx_nic *efx)
 {
-	struct siena_nic_data *nic_data = efx->nic_data;
 	efx_oword_t temp;
 	int rc;
 
@@ -336,16 +332,16 @@ static int siena_init_nic(struct efx_nic *efx)
 	efx_writeo(efx, &temp, FR_AZ_RX_CFG);
 
 	/* Enable IPv6 RSS */
-	BUILD_BUG_ON(sizeof(nic_data->ipv6_rss_key) !=
+	BUILD_BUG_ON(sizeof(efx->rx_hash_key) <
 		     2 * sizeof(temp) + FRF_CZ_RX_RSS_IPV6_TKEY_HI_WIDTH / 8 ||
 		     FRF_CZ_RX_RSS_IPV6_TKEY_HI_LBN != 0);
-	memcpy(&temp, nic_data->ipv6_rss_key, sizeof(temp));
+	memcpy(&temp, efx->rx_hash_key, sizeof(temp));
 	efx_writeo(efx, &temp, FR_CZ_RX_RSS_IPV6_REG1);
-	memcpy(&temp, nic_data->ipv6_rss_key + sizeof(temp), sizeof(temp));
+	memcpy(&temp, efx->rx_hash_key + sizeof(temp), sizeof(temp));
 	efx_writeo(efx, &temp, FR_CZ_RX_RSS_IPV6_REG2);
 	EFX_POPULATE_OWORD_2(temp, FRF_CZ_RX_RSS_IPV6_THASH_ENABLE, 1,
 			     FRF_CZ_RX_RSS_IPV6_IP_THASH_ENABLE, 1);
-	memcpy(&temp, nic_data->ipv6_rss_key + 2 * sizeof(temp),
+	memcpy(&temp, efx->rx_hash_key + 2 * sizeof(temp),
 	       FRF_CZ_RX_RSS_IPV6_TKEY_HI_WIDTH / 8);
 	efx_writeo(efx, &temp, FR_CZ_RX_RSS_IPV6_REG3);
 
-- 
1.6.2.5


-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
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 related

* [PATCH net-next-2.6 1/4] sfc: Fix reading of inserted hash
From: Ben Hutchings @ 2010-06-25 17:05 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-net-drivers
In-Reply-To: <1277485434.2094.13.camel@achroite.uk.solarflarecom.com>

The hash appears immediately before the packet data, not at the
beginning of the buffer. This means we can easily use negative offsets
from the start of packet data, so adjust the data and length at the
top of __efx_rx_packet() instead of wherever we consume the hash.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
 drivers/net/sfc/rx.c       |   11 ++++++-----
 drivers/net/sfc/selftest.c |    3 ---
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/net/sfc/rx.c b/drivers/net/sfc/rx.c
index 0fb9835..799c461 100644
--- a/drivers/net/sfc/rx.c
+++ b/drivers/net/sfc/rx.c
@@ -104,9 +104,9 @@ static inline unsigned int efx_rx_buf_size(struct efx_nic *efx)
 static inline u32 efx_rx_buf_hash(struct efx_rx_buffer *buf)
 {
 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) || NET_IP_ALIGN % 4 == 0
-	return __le32_to_cpup((const __le32 *)buf->data);
+	return __le32_to_cpup((const __le32 *)(buf->data - 4));
 #else
-	const u8 *data = (const u8 *)buf->data;
+	const u8 *data = (const u8 *)(buf->data - 4);
 	return ((u32)data[0]       |
 		(u32)data[1] << 8  |
 		(u32)data[2] << 16 |
@@ -469,8 +469,6 @@ static void efx_rx_packet_lro(struct efx_channel *channel,
 
 		if (efx->net_dev->features & NETIF_F_RXHASH)
 			skb->rxhash = efx_rx_buf_hash(rx_buf);
-		rx_buf->data += efx->type->rx_buffer_hash_size;
-		rx_buf->len -= efx->type->rx_buffer_hash_size;
 
 		skb_shinfo(skb)->frags[0].page = page;
 		skb_shinfo(skb)->frags[0].page_offset =
@@ -577,6 +575,9 @@ void __efx_rx_packet(struct efx_channel *channel,
 	struct efx_nic *efx = channel->efx;
 	struct sk_buff *skb;
 
+	rx_buf->data += efx->type->rx_buffer_hash_size;
+	rx_buf->len -= efx->type->rx_buffer_hash_size;
+
 	/* If we're in loopback test, then pass the packet directly to the
 	 * loopback layer, and free the rx_buf here
 	 */
@@ -589,11 +590,11 @@ void __efx_rx_packet(struct efx_channel *channel,
 	if (rx_buf->skb) {
 		prefetch(skb_shinfo(rx_buf->skb));
 
+		skb_reserve(rx_buf->skb, efx->type->rx_buffer_hash_size);
 		skb_put(rx_buf->skb, rx_buf->len);
 
 		if (efx->net_dev->features & NETIF_F_RXHASH)
 			rx_buf->skb->rxhash = efx_rx_buf_hash(rx_buf);
-		skb_pull(rx_buf->skb, efx->type->rx_buffer_hash_size);
 
 		/* Move past the ethernet header. rx_buf->data still points
 		 * at the ethernet header */
diff --git a/drivers/net/sfc/selftest.c b/drivers/net/sfc/selftest.c
index 0399be2..85f015f 100644
--- a/drivers/net/sfc/selftest.c
+++ b/drivers/net/sfc/selftest.c
@@ -258,9 +258,6 @@ void efx_loopback_rx_packet(struct efx_nic *efx,
 
 	payload = &state->payload;
 
-	buf_ptr += efx->type->rx_buffer_hash_size;
-	pkt_len -= efx->type->rx_buffer_hash_size;
-
 	received = (struct efx_loopback_payload *) buf_ptr;
 	received->ip.saddr = payload->ip.saddr;
 	if (state->offload_csum)
-- 
1.6.2.5


-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
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 related

* [PATCH net-next-2.6 0/4] More sfc changes for 2.6.36
From: Ben Hutchings @ 2010-06-25 17:03 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-net-drivers

Dave,

You appear to have applied all my previous patches to net-next-2.6, so
here are the fix-ups for hash insertion.  Also, an improvement in
hardware monitoring which has been in the the out-of-tree sfc driver for
a while but which I failed to carry over.

Ben.

Ben Hutchings (4):
  sfc: Fix reading of inserted hash
  sfc: Move siena_nic_data::ipv6_rss_key to efx_nic::rx_hash_key
  sfc: Use Toeplitz IPv4 hash for RSS and hash insertion
  sfc: Log clearer error messages for hardware monitor

 drivers/net/sfc/efx.c           |    3 +++
 drivers/net/sfc/falcon.c        |   14 ++++++++++++--
 drivers/net/sfc/falcon_boards.c |   11 ++++++++---
 drivers/net/sfc/net_driver.h    |    1 +
 drivers/net/sfc/nic.h           |    1 -
 drivers/net/sfc/rx.c            |   11 ++++++-----
 drivers/net/sfc/selftest.c      |    3 ---
 drivers/net/sfc/siena.c         |   23 ++++++++++++++---------
 8 files changed, 44 insertions(+), 23 deletions(-)

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
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

* dhclient, checksum and tap
From: Michael S. Tsirkin @ 2010-06-25 15:10 UTC (permalink / raw)
  To: Herbert Xu; +Cc: netdev

Hi!
I've been looking at the issue of checksum on
dhcp packets: to recap, 8dc4194474159660d7f37c495e3fc3f10d0db8cc
added a way for af_packet sockets to get the packet status.
Unfortunately not all dhcp clients caught up with
this development, so they are still broken
when both server and client run on the same host,
e.g. with bridge+tap.

And of course virtualization adds another way to run
old dhcp clients, so userspace virtio net in qemu has
a hack to detect DHCP and fill in the checksum.
I guess we could add this in vhost, as well.

However, one wonders whether the tap driver is a better place
for this work-around, that would help all users.
Any objections against putting such code in tap?

-- 
MST

^ permalink raw reply

* [PATCH ethtool 5/5] ethtool: Use named flag support to update extended offload flags
From: Ben Hutchings @ 2010-06-25 14:50 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: netdev, linux-net-drivers
In-Reply-To: <1277477027.2094.2.camel@achroite.uk.solarflarecom.com>

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
 ethtool.c |   70 ++++++++++--------------------------------------------------
 1 files changed, 12 insertions(+), 58 deletions(-)

diff --git a/ethtool.c b/ethtool.c
index a70cd03..4073745 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -277,10 +277,9 @@ static int off_sg_wanted = -1;
 static int off_tso_wanted = -1;
 static int off_ufo_wanted = -1;
 static int off_gso_wanted = -1;
-static int off_lro_wanted = -1;
+static u32 off_flags_wanted = 0;
+static u32 off_flags_unwanted = 0;
 static int off_gro_wanted = -1;
-static int off_ntuple_wanted = -1;
-static int off_rxhash_wanted = -1;
 
 static struct ethtool_pauseparam epause;
 static int gpause_changed = 0;
@@ -419,10 +418,13 @@ static struct cmdline_info cmdline_offload[] = {
 	{ "tso", CMDL_BOOL, &off_tso_wanted, NULL },
 	{ "ufo", CMDL_BOOL, &off_ufo_wanted, NULL },
 	{ "gso", CMDL_BOOL, &off_gso_wanted, NULL },
-	{ "lro", CMDL_BOOL, &off_lro_wanted, NULL },
+	{ "lro", CMDL_FLAG, &off_flags_wanted, NULL,
+	  ETH_FLAG_LRO, &off_flags_unwanted },
 	{ "gro", CMDL_BOOL, &off_gro_wanted, NULL },
-	{ "ntuple", CMDL_BOOL, &off_ntuple_wanted, NULL },
-	{ "rxhash", CMDL_BOOL, &off_rxhash_wanted, NULL },
+	{ "ntuple", CMDL_FLAG, &off_flags_wanted, NULL,
+	  ETH_FLAG_NTUPLE, &off_flags_unwanted },
+	{ "rxhash", CMDL_FLAG, &off_flags_wanted, NULL,
+	  ETH_FLAG_RXHASH, &off_flags_unwanted },
 };
 
 static struct cmdline_info cmdline_pause[] = {
@@ -2191,7 +2193,7 @@ static int do_soffload(int fd, struct ifreq *ifr)
 			return 90;
 		}
 	}
-	if (off_lro_wanted >= 0) {
+	if (off_flags_wanted || off_flags_unwanted) {
 		changed = 1;
 		eval.cmd = ETHTOOL_GFLAGS;
 		eval.data = 0;
@@ -2203,14 +2205,12 @@ static int do_soffload(int fd, struct ifreq *ifr)
 		}
 
 		eval.cmd = ETHTOOL_SFLAGS;
-		if (off_lro_wanted == 1)
-			eval.data |= ETH_FLAG_LRO;
-		else
-			eval.data &= ~ETH_FLAG_LRO;
+		eval.data = ((eval.data & ~off_flags_unwanted) |
+			     off_flags_wanted);
 
 		err = ioctl(fd, SIOCETHTOOL, ifr);
 		if (err) {
-			perror("Cannot set large receive offload settings");
+			perror("Cannot set device flag settings");
 			return 92;
 		}
 	}
@@ -2225,52 +2225,6 @@ static int do_soffload(int fd, struct ifreq *ifr)
 			return 93;
 		}
 	}
-	if (off_ntuple_wanted >= 0) {
-		changed = 1;
-		eval.cmd = ETHTOOL_GFLAGS;
-		eval.data = 0;
-		ifr->ifr_data = (caddr_t)&eval;
-		err = ioctl(fd, SIOCETHTOOL, ifr);
-		if (err) {
-			perror("Cannot get device flag settings");
-			return 91;
-		}
-
-		eval.cmd = ETHTOOL_SFLAGS;
-		if (off_ntuple_wanted == 1)
-			eval.data |= ETH_FLAG_NTUPLE;
-		else
-			eval.data &= ~ETH_FLAG_NTUPLE;
-
-		err = ioctl(fd, SIOCETHTOOL, ifr);
-		if (err) {
-			perror("Cannot set n-tuple filter settings");
-			return 93;
-		}
-	}
-	if (off_rxhash_wanted >= 0) {
-		changed = 1;
-		eval.cmd = ETHTOOL_GFLAGS;
-		eval.data = 0;
-		ifr->ifr_data = (caddr_t)&eval;
-		err = ioctl(fd, SIOCETHTOOL, ifr);
-		if (err) {
-			perror("Cannot get device flag settings");
-			return 91;
-		}
-
-		eval.cmd = ETHTOOL_SFLAGS;
-		if (off_rxhash_wanted)
-			eval.data |= ETH_FLAG_RXHASH;
-		else
-			eval.data &= ~ETH_FLAG_RXHASH;
-
-		err = ioctl(fd, SIOCETHTOOL, ifr);
-		if (err) {
-			perror("Cannot set receive hash settings");
-			return 93;
-		}
-	}
 
 	if (!changed) {
 		fprintf(stdout, "no offload settings changed\n");
-- 
1.6.2.5

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
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 related

* [PATCH ethtool 4/5] ethtool: Implement named message type flags
From: Ben Hutchings @ 2010-06-25 14:49 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: netdev, linux-net-drivers
In-Reply-To: <1277477027.2094.2.camel@achroite.uk.solarflarecom.com>

Allow message type flags to be turned on and off by name.
Print the names of the currently set flags below the numeric value.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
 ethtool.8 |   66 +++++++++++++++++++++++++++++++++++++--
 ethtool.c |  104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 156 insertions(+), 14 deletions(-)

diff --git a/ethtool.8 b/ethtool.8
index a7b43d5..5983d0e 100644
--- a/ethtool.8
+++ b/ethtool.8
@@ -200,7 +200,10 @@ ethtool \- Display or change ethernet card settings
 .RB [ wol \ \*(WO]
 .RB [ sopass \ \*(MA]
 .RB [ msglvl
-.IR N ]
+.IR N \ |
+.BI msglvl \ type
+.A1 on off
+.RB ...]
 
 .B ethtool \-n
 .I ethX
@@ -482,9 +485,66 @@ Disable (wake on nothing).  This option clears all previous options.
 .B sopass \*(MA\c
 Sets the SecureOn(tm) password.  The argument to this option must be 6
 bytes in ethernet MAC hex format (\*(MA).
-.TP
+.PP
 .BI msglvl \ N
-Sets the driver message level. Meanings differ per driver.
+.br
+.BI msglvl \ type
+.A1 on off
+.RB ...
+.RS
+Sets the driver message type flags by name or number. \fItype\fR
+names the type of message to enable or disable; \fIN\fR specifies the
+new flags numerically. The defined type names and numbers are:
+.PD 0
+.TP 12
+.B drv
+0x0001  General driver status
+.TP 12
+.B probe
+0x0002  Hardware probing
+.TP 12
+.B link
+0x0004  Link state
+.TP 12
+.B timer
+0x0008  Periodic status check
+.TP 12
+.B ifdown
+0x0010  Interface being brought down
+.TP 12
+.B ifup
+0x0020  Interface being brought up
+.TP 12
+.B rx_err
+0x0040  Receive error
+.TP 12
+.B tx_err
+0x0080  Transmit error
+.TP 12
+.B tx_queued
+0x0100  Transmit queueing
+.TP 12
+.B intr
+0x0200  Interrupt handling
+.TP 12
+.B tx_done
+0x0400  Transmit completion
+.TP 12
+.B rx_status
+0x0800  Receive completion
+.TP 12
+.B pktdata
+0x1000  Packet contents
+.TP 12
+.B hw
+0x2000  Hardware status
+.TP 12
+.B wol
+0x4000  Wake-on-LAN status
+.PP
+The precise meanings of these type flags differ between drivers.
+.PD
+.RE
 .TP
 .B \-n \-\-show-nfc
 Retrieves the receive network flow classification configurations.
diff --git a/ethtool.c b/ethtool.c
index 4adab4b..a70cd03 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -20,7 +20,6 @@
  *   * better man page (steal from mii-tool?)
  *   * fall back on SIOCMII* ioctl()s and possibly SIOCDEVPRIVATE*
  *   * abstract ioctls to allow for fallback modes of data gathering
- *   * symbolic names for msglvl bitmask
  */
 
 #ifdef HAVE_CONFIG_H
@@ -39,6 +38,7 @@
 #include <net/if.h>
 #include <sys/utsname.h>
 #include <limits.h>
+#include <ctype.h>
 
 #include <linux/sockios.h>
 #include "ethtool-util.h"
@@ -51,6 +51,26 @@
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 #endif
 
+#ifndef HAVE_NETIF_MSG
+enum {
+	NETIF_MSG_DRV		= 0x0001,
+	NETIF_MSG_PROBE		= 0x0002,
+	NETIF_MSG_LINK		= 0x0004,
+	NETIF_MSG_TIMER		= 0x0008,
+	NETIF_MSG_IFDOWN	= 0x0010,
+	NETIF_MSG_IFUP		= 0x0020,
+	NETIF_MSG_RX_ERR	= 0x0040,
+	NETIF_MSG_TX_ERR	= 0x0080,
+	NETIF_MSG_TX_QUEUED	= 0x0100,
+	NETIF_MSG_INTR		= 0x0200,
+	NETIF_MSG_TX_DONE	= 0x0400,
+	NETIF_MSG_RX_STATUS	= 0x0800,
+	NETIF_MSG_PKTDATA	= 0x1000,
+	NETIF_MSG_HW		= 0x2000,
+	NETIF_MSG_WOL		= 0x4000,
+};
+#endif
+
 static int parse_wolopts(char *optstr, u32 *data);
 static char *unparse_wolopts(int wolopts);
 static int parse_sopass(char *src, unsigned char *dest);
@@ -126,7 +146,7 @@ static struct option {
 		"		[ xcvr internal|external ]\n"
 		"		[ wol p|u|m|b|a|g|s|d... ]\n"
 		"		[ sopass %x:%x:%x:%x:%x:%x ]\n"
-		"		[ msglvl %d ] \n" },
+		"		[ msglvl %d | msglvl type on|off ... ]\n" },
     { "-a", "--show-pause", MODE_GPAUSE, "Show pause options" },
     { "-A", "--pause", MODE_SPAUSE, "Set pause options",
       "		[ autoneg on|off ]\n"
@@ -313,7 +333,6 @@ static int wol_change = 0;
 static u8 sopass_wanted[SOPASS_MAX];
 static int sopass_change = 0;
 static int gwol_changed = 0; /* did anything in GWOL change? */
-static int msglvl_wanted = -1;
 static int phys_id_time = 0;
 static int gregs_changed = 0;
 static int gregs_dump_raw = 0;
@@ -337,6 +356,11 @@ static struct ethtool_rx_ntuple_flow_spec ntuple_fs;
 static char *flash_file = NULL;
 static int flash = -1;
 static int flash_region = -1;
+
+static int msglvl_changed;
+static u32 msglvl_wanted = 0;
+static u32 msglvl_unwanted =0;
+
 static enum {
 	ONLINE=0,
 	OFFLINE,
@@ -455,6 +479,39 @@ static struct cmdline_info cmdline_ntuple[] = {
 	{ "action", CMDL_S32, &ntuple_fs.action, NULL },
 };
 
+static struct cmdline_info cmdline_msglvl[] = {
+	{ "drv", CMDL_FLAG, &msglvl_wanted, NULL,
+	  NETIF_MSG_DRV, &msglvl_unwanted },
+	{ "probe", CMDL_FLAG, &msglvl_wanted, NULL,
+	  NETIF_MSG_PROBE, &msglvl_unwanted },
+	{ "link", CMDL_FLAG, &msglvl_wanted, NULL,
+	  NETIF_MSG_LINK, &msglvl_unwanted },
+	{ "timer", CMDL_FLAG, &msglvl_wanted, NULL,
+	  NETIF_MSG_TIMER, &msglvl_unwanted },
+	{ "ifdown", CMDL_FLAG, &msglvl_wanted, NULL,
+	  NETIF_MSG_IFDOWN, &msglvl_unwanted },
+	{ "ifup", CMDL_FLAG, &msglvl_wanted, NULL,
+	  NETIF_MSG_IFUP, &msglvl_unwanted },
+	{ "rx_err", CMDL_FLAG, &msglvl_wanted, NULL,
+	  NETIF_MSG_RX_ERR, &msglvl_unwanted },
+	{ "tx_err", CMDL_FLAG, &msglvl_wanted, NULL,
+	  NETIF_MSG_TX_ERR, &msglvl_unwanted },
+	{ "tx_queued", CMDL_FLAG, &msglvl_wanted, NULL,
+	  NETIF_MSG_TX_QUEUED, &msglvl_unwanted },
+	{ "intr", CMDL_FLAG, &msglvl_wanted, NULL,
+	  NETIF_MSG_INTR, &msglvl_unwanted },
+	{ "tx_done", CMDL_FLAG, &msglvl_wanted, NULL,
+	  NETIF_MSG_TX_DONE, &msglvl_unwanted },
+	{ "rx_status", CMDL_FLAG, &msglvl_wanted, NULL,
+	  NETIF_MSG_RX_STATUS, &msglvl_unwanted },
+	{ "pktdata", CMDL_FLAG, &msglvl_wanted, NULL,
+	  NETIF_MSG_PKTDATA, &msglvl_unwanted },
+	{ "hw", CMDL_FLAG, &msglvl_wanted, NULL,
+	  NETIF_MSG_HW, &msglvl_unwanted },
+	{ "wol", CMDL_FLAG, &msglvl_wanted, NULL,
+	  NETIF_MSG_WOL, &msglvl_unwanted },
+};
+
 static long long
 get_int_range(char *str, int base, long long min, long long max)
 {
@@ -920,7 +977,20 @@ static void parse_cmdline(int argc, char **argp)
 				i++;
 				if (i >= argc)
 					show_usage(1);
-				msglvl_wanted = get_int(argp[i], 0);
+				if (isdigit((unsigned char)argp[i][0])) {
+					msglvl_changed = 1;
+					msglvl_unwanted = ~0;
+					msglvl_wanted =
+						get_uint_range(argp[i], 0,
+							       0xffffffff);
+				} else {
+					parse_generic_cmdline(
+						argc, argp, i,
+						&msglvl_changed,
+						cmdline_msglvl,
+						ARRAY_SIZE(cmdline_msglvl));
+					i = argc;
+				}
 				break;
 			}
 			show_usage(1);
@@ -2247,8 +2317,12 @@ static int do_gset(int fd, struct ifreq *ifr)
 	ifr->ifr_data = (caddr_t)&edata;
 	err = send_ioctl(fd, ifr);
 	if (err == 0) {
-		fprintf(stdout, "	Current message level: 0x%08x (%d)\n",
+		fprintf(stdout, "	Current message level: 0x%08x (%d)\n"
+			"			       ",
 			edata.data, edata.data);
+		print_flags(cmdline_msglvl, ARRAY_SIZE(cmdline_msglvl),
+			    edata.data);
+		fprintf(stdout, "\n");
 		allfail = 0;
 	} else if (errno != EOPNOTSUPP) {
 		perror("Cannot get message level");
@@ -2371,15 +2445,23 @@ static int do_sset(int fd, struct ifreq *ifr)
 		}
 	}
 
-	if (msglvl_wanted != -1) {
+	if (msglvl_changed) {
 		struct ethtool_value edata;
 
-		edata.cmd = ETHTOOL_SMSGLVL;
-		edata.data = msglvl_wanted;
-		ifr->ifr_data = (caddr_t)&edata;;
+		edata.cmd = ETHTOOL_GMSGLVL;
+		ifr->ifr_data = (caddr_t)&edata;
 		err = send_ioctl(fd, ifr);
-		if (err < 0)
-			perror("Cannot set new msglvl");
+		if (err < 0) {
+			perror("Cannot get msglvl");
+		} else {
+			edata.cmd = ETHTOOL_SMSGLVL;
+			edata.data = ((edata.data & ~msglvl_unwanted) |
+				      msglvl_wanted);
+			ifr->ifr_data = (caddr_t)&edata;
+			err = send_ioctl(fd, ifr);
+			if (err < 0)
+				perror("Cannot set new msglvl");
+		}
 	}
 
 	return 0;
-- 
1.6.2.5


-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
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 related

* [PATCH ethtool 3/5] ethtool: Add support for named flags
From: Ben Hutchings @ 2010-06-25 14:49 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: netdev, linux-net-drivers
In-Reply-To: <1277477027.2094.2.camel@achroite.uk.solarflarecom.com>

Define an argument type CMDL_FLAG, which can be used to set and
clear flags.  For each setting that can be modified in this way,
the flags to be set and cleared are accumulated in two variables.

Add support for CMDL_FLAGS parse_generic_cmdline().

Add utility function print_flags().

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
print_flags() is unused here, but will be used in the next patch.

Ben.

 ethtool.c |   40 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 39 insertions(+), 1 deletions(-)

diff --git a/ethtool.c b/ethtool.c
index d4bf5a8..4adab4b 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -352,14 +352,21 @@ typedef enum {
 	CMDL_BE16,
 	CMDL_BE32,
 	CMDL_STR,
+	CMDL_FLAG,
 } cmdline_type_t;
 
 struct cmdline_info {
 	const char *name;
 	cmdline_type_t type;
-	/* Points to int (BOOL), s32, u16, u32, u64 or char * (STR) */
+	/* Points to int (BOOL), s32, u16, u32 (U32/FLAG), u64 or
+	 * char * (STR).  For FLAG, the value accumulates all flags
+	 * to be set. */
 	void *wanted_val;
 	void *ioctl_val;
+	/* For FLAG, the flag value to be set/cleared */
+	u32 flag_val;
+	/* For FLAG, accumulates all flags to be cleared */
+	u32 *unwanted_val;
 };
 
 static struct cmdline_info cmdline_gregs[] = {
@@ -550,6 +557,17 @@ static void parse_generic_cmdline(int argc, char **argp,
 							       0xffffffff));
 					break;
 				}
+				case CMDL_FLAG: {
+					u32 *p;
+					if (!strcmp(argp[i], "on"))
+						p = info[idx].wanted_val;
+					else if (!strcmp(argp[i], "off"))
+						p = info[idx].unwanted_val;
+					else
+						show_usage(1);
+					*p |= info[idx].flag_val;
+					break;
+				}
 				case CMDL_STR: {
 					char **s = info[idx].wanted_val;
 					*s = strdup(argp[i]);
@@ -566,6 +584,26 @@ static void parse_generic_cmdline(int argc, char **argp,
 	}
 }
 
+static void
+print_flags(const struct cmdline_info *info, unsigned int n_info, u32 value)
+{
+	const char *sep = "";
+
+	while (n_info) {
+		if (info->type == CMDL_FLAG && value & info->flag_val) {
+			printf("%s%s", sep, info->name);
+			sep = " ";
+			value &= ~info->flag_val;
+		}
+		++info;
+		--n_info;
+	}
+
+	/* Print any unrecognised flags in hex */
+	if (value)
+		printf("%s%#x", sep, value);
+}
+
 static int rxflow_str_to_type(const char *str)
 {
 	int flow_type = 0;
-- 
1.6.2.5


-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
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 related

* [PATCH ethtool 2/5] ethtool: Mark show_usage() as noreturn
From: Ben Hutchings @ 2010-06-25 14:48 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: netdev, linux-net-drivers
In-Reply-To: <1277477027.2094.2.camel@achroite.uk.solarflarecom.com>


Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
This prevents the next patch from provoking an incorrect warning about
an uninitialised variable.

Ben.

 ethtool.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/ethtool.c b/ethtool.c
index 8969390..d4bf5a8 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -220,6 +220,8 @@ static struct option {
 };
 

+static void show_usage(int badarg) __attribute__((noreturn));
+
 static void show_usage(int badarg)
 {
 	int i;
-- 
1.6.2.5


-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
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 related


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