Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH] gigaset: call module_put before restart of if_open()
From: David Miller @ 2011-06-17 19:28 UTC (permalink / raw)
  To: shved
  Cc: hjlipp, tilman, isdn, gigaset307x-common, netdev, linux-kernel,
	ldv-project
In-Reply-To: <1308327913-23220-2-git-send-email-shved@ispras.ru>

From: Pavel Shved <shved@ispras.ru>
Date: Fri, 17 Jun 2011 20:25:11 +0400

> if_open() calls try_module_get(), and after an attempt to lock a mutex
> the if_open() function may return -ERESTARTSYS without
> putting the module.  Then, when if_open() is executed again,
> try_module_get() is called making the reference counter of THIS_MODULE
> greater than one at successful exit from if_open().  The if_close()
> function puts the module only once, and as a result it can't be
> unloaded.
> 
> This patch adds module_put call before the return from if_open().
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Pavel Shved <shved@ispras.ru>

Applied.

^ permalink raw reply

* Re: [PATCH] farsync: add module_put to error path in fst_open()
From: David Miller @ 2011-06-17 19:28 UTC (permalink / raw)
  To: shved; +Cc: kevin.curtis, netdev, linux-kernel, ldv-project
In-Reply-To: <1308327913-23220-1-git-send-email-shved@ispras.ru>

From: Pavel Shved <shved@ispras.ru>
Date: Fri, 17 Jun 2011 20:25:10 +0400

> The fst_open() function, after a successful try_module_get() may return
> an error code if hdlc_open() returns it.  However, it does not put the
> module on this error path.
> 
> This patch adds the necessary module_put() call.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Pavel Shved <shved@ispras.ru>

Applied.

^ permalink raw reply

* [PATCH] ethtool:  Support get/set rx-save-fcs flag.
From: greearb @ 2011-06-17 19:35 UTC (permalink / raw)
  To: netdev, bhutchings; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

This allows users to receive the Ethernet frame checksum
on supported drivers.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---

v2:  Make names more consistent.

:100644 100644 c7a18f7... c059852... M	ethtool-copy.h
:100644 100644 7b1cdf5... 66a00d5... M	ethtool.8.in
:100644 100644 c189c78... b97552c... M	ethtool.c
 ethtool-copy.h |    2 ++
 ethtool.8.in   |   18 ++++++++++++++++++
 ethtool.c      |   55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 74 insertions(+), 1 deletions(-)

diff --git a/ethtool-copy.h b/ethtool-copy.h
index c7a18f7..c059852 100644
--- a/ethtool-copy.h
+++ b/ethtool-copy.h
@@ -751,6 +751,8 @@ enum ethtool_sfeatures_retval_bits {
 #define ETHTOOL_SET_DUMP	0x0000003e /* Set dump settings */
 #define ETHTOOL_GET_DUMP_FLAG	0x0000003f /* Get dump settings */
 #define ETHTOOL_GET_DUMP_DATA	0x00000040 /* Get dump data */
+#define ETHTOOL_GET_SAVE_RXFCS	0x00000041 /* Get RX Save Frame Checksum */
+#define ETHTOOL_SET_SAVE_RXFCS	0x00000042 /* Set RX Save Frame Checksum */
 
 /* compatibility with older code */
 #define SPARC_ETH_GSET		ETHTOOL_GSET
diff --git a/ethtool.8.in b/ethtool.8.in
index 7b1cdf5..66a00d5 100644
--- a/ethtool.8.in
+++ b/ethtool.8.in
@@ -274,6 +274,13 @@ ethtool \- query or control network driver and hardware settings
 .IR W1
 .RB ...\ ]
 .HP
+.B ethtool \-z|\-\-get\-rxfcs
+.I ethX
+.HP
+.B ethtool\ \-Z|\-\-set\-rxfcs
+.I ethX
+.BI \ N
+.HP
 .B ethtool \-f|\-\-flash
 .I ethX
 .RI FILE
@@ -630,6 +637,17 @@ Sets the receive flow hash indirection table to spread flows between
 receive queues according to the given weights.  The sum of the weights
 must be non-zero and must not exceed the size of the indirection table.
 .TP
+.B \-z \-\-show\-rxfcs
+Retrieves the receive frame checksum flag.
+.TP
+.B \-Z \-\-set\-rxcfs
+Configures the receive frame checksum flag.
+.TP
+.B N
+1 means enable, 0 means disable.  When enabled, the 4-byte
+Frame Checksum will be appended to the end of the packet.  This
+can be useful when sniffing packets.
+.TP
 .B \-f \-\-flash \ FILE
 Flash firmware image from the specified file to a region on the adapter.
 By default this will flash all the regions on the adapter.
diff --git a/ethtool.c b/ethtool.c
index c189c78..b97552c 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -99,6 +99,8 @@ static int do_flash(int fd, struct ifreq *ifr);
 static int do_permaddr(int fd, struct ifreq *ifr);
 static int do_getfwdump(int fd, struct ifreq *ifr);
 static int do_setfwdump(int fd, struct ifreq *ifr);
+static int do_set_save_rxfcs(int fd, struct ifreq *ifr);
+static int do_get_save_rxfcs(int fd, struct ifreq *ifr);
 
 static int send_ioctl(int fd, struct ifreq *ifr);
 
@@ -133,6 +135,8 @@ static enum {
 	MODE_PERMADDR,
 	MODE_SET_DUMP,
 	MODE_GET_DUMP,
+	MODE_SET_SAVE_RXFCS,
+	MODE_GET_SAVE_RXFCS,
 } mode = MODE_GSET;
 
 static struct option {
@@ -266,6 +270,11 @@ static struct option {
     { "-W", "--set-dump", MODE_SET_DUMP,
 		"Set dump flag of the device",
 		"		N\n"},
+    { "-z", "--get-save-rxfcs", MODE_GET_SAVE_RXFCS,
+		"Get Save RX-FCS flag" },
+    { "-Z", "--set-save-rxfcs", MODE_SET_SAVE_RXFCS,
+		"Set Save RX-FCS flag of the device",
+		"		N\n"},
     { "-h", "--help", MODE_HELP, "Show this help" },
     { NULL, "--version", MODE_VERSION, "Show version number" },
     {}
@@ -398,6 +407,7 @@ static u32 msglvl_wanted = 0;
 static u32 msglvl_mask = 0;
 static u32 dump_flag;
 static char *dump_file = NULL;
+static u32 save_rxfcs_flag;
 
 static int rx_class_rule_get = -1;
 static int rx_class_rule_del = -1;
@@ -792,7 +802,9 @@ static void parse_cmdline(int argc, char **argp)
 			    (mode == MODE_FLASHDEV) ||
 			    (mode == MODE_PERMADDR) ||
 			    (mode == MODE_SET_DUMP) ||
-			    (mode == MODE_GET_DUMP)) {
+			    (mode == MODE_GET_DUMP) ||
+			    (mode == MODE_SET_SAVE_RXFCS) ||
+			    (mode == MODE_GET_SAVE_RXFCS)) {
 				devname = argp[i];
 				break;
 			}
@@ -817,6 +829,9 @@ static void parse_cmdline(int argc, char **argp)
 			} else if (mode == MODE_SET_DUMP) {
 				dump_flag = get_u32(argp[i], 0);
 				break;
+			} else if (mode == MODE_SET_SAVE_RXFCS) {
+				save_rxfcs_flag = get_u32(argp[i], 0);
+				break;
 			}
 			/* fallthrough */
 		default:
@@ -1935,6 +1950,10 @@ static int doit(void)
 		return do_getfwdump(fd, &ifr);
 	} else if (mode == MODE_SET_DUMP) {
 		return do_setfwdump(fd, &ifr);
+	} else if (mode == MODE_GET_SAVE_RXFCS) {
+		return do_get_save_rxfcs(fd, &ifr);
+	} else if (mode == MODE_SET_SAVE_RXFCS) {
+		return do_set_save_rxfcs(fd, &ifr);
 	}
 
 	return 69;
@@ -3322,6 +3341,40 @@ static int do_setfwdump(int fd, struct ifreq *ifr)
 	return 0;
 }
 
+static int do_set_save_rxfcs(int fd, struct ifreq *ifr)
+{
+	int err;
+	struct ethtool_value edata;
+
+	edata.cmd = ETHTOOL_SET_SAVE_RXFCS;
+	edata.data = save_rxfcs_flag;
+	ifr->ifr_data = (caddr_t)&edata;
+	err = send_ioctl(fd, ifr);
+	if (err < 0) {
+		perror("Can not set Save RX FCS level\n");
+		return 1;
+	}
+	return 0;
+}
+
+static int do_get_save_rxfcs(int fd, struct ifreq *ifr)
+{
+	int err;
+	struct ethtool_value edata;
+
+	edata.cmd = ETHTOOL_GET_SAVE_RXFCS;
+	ifr->ifr_data = (caddr_t)&edata;
+	err = send_ioctl(fd, ifr);
+	if (err == 0) {
+		fprintf(stdout, "	Save RX-FCS %s\n",
+			edata.data ? "Enabled" : "Disabled");
+		return 0;
+	} else {
+		perror("Can not get Save RX FCS flag\n");
+		return 1;
+	}
+}
+
 static int send_ioctl(int fd, struct ifreq *ifr)
 {
 	return ioctl(fd, SIOCETHTOOL, ifr);
-- 
1.7.3.4


^ permalink raw reply related

* [PATCH 0/2] Allow NICs to pass Frame Checksum up the stack.
From: greearb @ 2011-06-17 19:40 UTC (permalink / raw)
  To: netdev; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

This series provides ethtool support to set and get the rx-checksum
flag, and adds support to the e100 driver.

Assuming this series is acceptable, I would then propose a series of patches
to allow receiving all frames, even ones with bad checksums, etc.

And if that is acceptable, a third series would allow user-space to generate
packets with custom ethernet frame checksums (ie, bad ones if desired).

And finally, more drivers, such as e1000 and hopefully e100e can
be supported.

v2:  Make naming more consistent, use get/set_value.

Ben Greear (2):
  net:  Support getting/setting RX-FCS in drivers.
  e100:  Support receiving Ethernet FCS.

 drivers/net/e100.c      |   35 ++++++++++++++++++++++++++++++++---
 include/linux/ethtool.h |    8 ++++++++
 net/core/ethtool.c      |    8 ++++++++
 3 files changed, 48 insertions(+), 3 deletions(-)

-- 
1.7.3.4


^ permalink raw reply

* [PATCH 1/2] net:  Support getting/setting RX-FCS in drivers.
From: greearb @ 2011-06-17 19:40 UTC (permalink / raw)
  To: netdev; +Cc: Ben Greear
In-Reply-To: <1308339615-5866-1-git-send-email-greearb@candelatech.com>

From: Ben Greear <greearb@candelatech.com>

This will allow us to enable/disable having the Ethernet
frame checksum appended to the skb.  Enabling this is
useful when sniffing packets.

In particular, this can be used to test logic that allows
a NIC to receive all frames, even ones with bad checksums.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
:100644 100644 439b173... 675ddc0... M	include/linux/ethtool.h
:100644 100644 fd14116... 0e01860... M	net/core/ethtool.c
 include/linux/ethtool.h |    8 ++++++++
 net/core/ethtool.c      |    8 ++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 439b173..675ddc0 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -877,6 +877,9 @@ bool ethtool_invalid_flags(struct net_device *dev, u32 data, u32 supported);
  * 		   and flag of the device.
  * @get_dump_data: Get dump data.
  * @set_dump: Set dump specific flags to the device.
+ * @set_save_rxfcs:  Set flag to save (1), or discard (0), the Ethernet
+ *	Frame Checksum for received packets.
+ * @get_save_rxfcs:  Get current value for Save RX-FCS flag.
  *
  * All operations are optional (i.e. the function pointer may be set
  * to %NULL) and callers must take this into account.  Callers must
@@ -955,6 +958,8 @@ struct ethtool_ops {
 	int	(*get_dump_data)(struct net_device *,
 				 struct ethtool_dump *, void *);
 	int	(*set_dump)(struct net_device *, struct ethtool_dump *);
+	int	(*set_save_rxfcs)(struct net_device *, u32);
+	u32	(*get_save_rxfcs)(struct net_device *);
 
 };
 #endif /* __KERNEL__ */
@@ -1029,6 +1034,9 @@ struct ethtool_ops {
 #define ETHTOOL_SET_DUMP	0x0000003e /* Set dump settings */
 #define ETHTOOL_GET_DUMP_FLAG	0x0000003f /* Get dump settings */
 #define ETHTOOL_GET_DUMP_DATA	0x00000040 /* Get dump data */
+#define ETHTOOL_GET_SAVE_RXFCS	0x00000041 /* Get RX Save Frame Checksum */
+#define ETHTOOL_SET_SAVE_RXFCS	0x00000042 /* Set RX Save Frame Checksum */
+
 
 /* compatibility with older code */
 #define SPARC_ETH_GSET		ETHTOOL_GSET
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index fd14116..0e01860 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -2152,6 +2152,14 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
 	case ETHTOOL_GET_DUMP_DATA:
 		rc = ethtool_get_dump_data(dev, useraddr);
 		break;
+	case ETHTOOL_SET_SAVE_RXFCS:
+		rc = ethtool_set_value(dev, useraddr,
+				       dev->ethtool_ops->set_save_rxfcs);
+		break;
+	case ETHTOOL_GET_SAVE_RXFCS:
+		rc =  ethtool_get_value(dev, useraddr, ethcmd,
+					dev->ethtool_ops->get_save_rxfcs);
+		break;
 	default:
 		rc = -EOPNOTSUPP;
 	}
-- 
1.7.3.4


^ permalink raw reply related

* [PATCH 2/2] e100:  Support receiving Ethernet FCS.
From: greearb @ 2011-06-17 19:40 UTC (permalink / raw)
  To: netdev; +Cc: Ben Greear
In-Reply-To: <1308339615-5866-1-git-send-email-greearb@candelatech.com>

From: Ben Greear <greearb@candelatech.com>

Helps when sniffing packets.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
:100644 100644 e336c79... 647d8c6... M	drivers/net/e100.c
 drivers/net/e100.c |   35 ++++++++++++++++++++++++++++++++---
 1 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index e336c79..647d8c6 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -587,6 +587,7 @@ struct nic {
 		multicast_all      = (1 << 2),
 		wol_magic          = (1 << 3),
 		ich_10h_workaround = (1 << 4),
+		save_rxfcs         = (1 << 5),
 	} flags					____cacheline_aligned;
 
 	enum mac mac;
@@ -1130,6 +1131,9 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
 		config->promiscuous_mode = 0x1;		/* 1=on, 0=off */
 	}
 
+	if (nic->flags & save_rxfcs)
+		config->rx_crc_transfer = 0x1;	/* 1=save, 0=discard */
+
 	if (nic->flags & multicast_all)
 		config->multicast_all = 0x1;		/* 1=accept, 0=no */
 
@@ -1917,6 +1921,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
 	struct sk_buff *skb = rx->skb;
 	struct rfd *rfd = (struct rfd *)skb->data;
 	u16 rfd_status, actual_size;
+	u16 rxfcs_pad = 0;
 
 	if (unlikely(work_done && *work_done >= work_to_do))
 		return -EAGAIN;
@@ -1949,9 +1954,12 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
 	}
 
 	/* Get actual data size */
+	if (nic->flags & save_rxfcs)
+		rxfcs_pad = 4;
 	actual_size = le16_to_cpu(rfd->actual_size) & 0x3FFF;
-	if (unlikely(actual_size > RFD_BUF_LEN - sizeof(struct rfd)))
-		actual_size = RFD_BUF_LEN - sizeof(struct rfd);
+	if (unlikely(actual_size >
+		     RFD_BUF_LEN + rxfcs_pad - sizeof(struct rfd)))
+		actual_size = RFD_BUF_LEN + rxfcs_pad - sizeof(struct rfd);
 
 	/* Get data */
 	pci_unmap_single(nic->pdev, rx->dma_addr,
@@ -1978,7 +1986,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
 	if (unlikely(!(rfd_status & cb_ok))) {
 		/* Don't indicate if hardware indicates errors */
 		dev_kfree_skb_any(skb);
-	} else if (actual_size > ETH_DATA_LEN + VLAN_ETH_HLEN) {
+	} else if (actual_size > ETH_DATA_LEN + VLAN_ETH_HLEN + rxfcs_pad) {
 		/* Don't indicate oversized frames */
 		nic->rx_over_length_errors++;
 		dev_kfree_skb_any(skb);
@@ -2370,6 +2378,25 @@ static int e100_set_settings(struct net_device *netdev, struct ethtool_cmd *cmd)
 	return err;
 }
 
+static int e100_set_save_rxfcs(struct net_device *netdev, u32 data)
+{
+	struct nic *nic = netdev_priv(netdev);
+	if (data)
+		nic->flags |= save_rxfcs;
+	else
+		nic->flags &= ~save_rxfcs;
+
+	e100_exec_cb(nic, NULL, e100_configure);
+
+	return 0;
+}
+
+static u32 e100_get_save_rxfcs(struct net_device *netdev)
+{
+	struct nic *nic = netdev_priv(netdev);
+	return !!(nic->flags & save_rxfcs);
+}
+
 static void e100_get_drvinfo(struct net_device *netdev,
 	struct ethtool_drvinfo *info)
 {
@@ -2689,6 +2716,8 @@ static const struct ethtool_ops e100_ethtool_ops = {
 	.set_phys_id		= e100_set_phys_id,
 	.get_ethtool_stats	= e100_get_ethtool_stats,
 	.get_sset_count		= e100_get_sset_count,
+	.set_save_rxfcs		= e100_set_save_rxfcs,
+	.get_save_rxfcs		= e100_get_save_rxfcs,
 };
 
 static int e100_do_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
-- 
1.7.3.4


^ permalink raw reply related

* [PATCH net-next 0/4] Pull request for 'davem-next.r8169' branch
From: Francois Romieu @ 2011-06-17 19:28 UTC (permalink / raw)
  To: davem; +Cc: netdev, Realtek linux nic maintainers, Hayes Wang, Ben Hutchings

Please pull from branch 'davem-next.r8169' in repository

git://git.kernel.org/pub/scm/linux/kernel/git/romieu/netdev-2.6.git davem-next.r8169

to get the changes below.

Distance from 'davem-next' (c4dc4d108ace27cc0c594b67bd6bd945deaac8c2)
---------------------------------------------------------------------

1e79a76080ef7685d58fb977308b0854f2913818
40e4c935d4a74c03911654027a81f3a924022ccb
3883c49dadb94083d57436d0ed7348cbeaaa4bef
f5410a55194f7556bbc77f5e37009866c0c98673

Diffstat
--------

 drivers/net/r8169.c |  216 +++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 166 insertions(+), 50 deletions(-)

Shortlog
--------

Francois Romieu (3):
      r8169: move the firmware down into the device private data.
      r8169: explicit firmware format check.
      r8169: check firmware content sooner.

Hayes Wang (1):
      r8169: support new firmware format.

Patch
-----

diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 7310824..e16929d 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -667,7 +667,18 @@ struct rtl8169_private {
 	struct rtl8169_counters counters;
 	u32 saved_wolopts;
 
-	const struct firmware *fw;
+	struct rtl_fw {
+		const struct firmware *fw;
+
+#define RTL_VER_SIZE		32
+
+		char version[RTL_VER_SIZE];
+
+		struct rtl_fw_phy_action {
+			__le32 *code;
+			size_t size;
+		} phy_action;
+	} *rtl_fw;
 #define RTL_FIRMWARE_UNKNOWN	ERR_PTR(-EAGAIN);
 };
 
@@ -1222,12 +1233,13 @@ static void rtl8169_get_drvinfo(struct net_device *dev,
 				struct ethtool_drvinfo *info)
 {
 	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl_fw *rtl_fw = tp->rtl_fw;
 
 	strcpy(info->driver, MODULENAME);
 	strcpy(info->version, RTL8169_VERSION);
 	strcpy(info->bus_info, pci_name(tp->pci_dev));
-	strncpy(info->fw_version, IS_ERR_OR_NULL(tp->fw) ? "N/A" :
-		rtl_lookup_firmware_name(tp), sizeof(info->fw_version) - 1);
+	strncpy(info->fw_version, IS_ERR_OR_NULL(rtl_fw) ? "N/A" :
+		rtl_fw->version, RTL_VER_SIZE);
 }
 
 static int rtl8169_get_regs_len(struct net_device *dev)
@@ -1741,21 +1753,75 @@ static void rtl_writephy_batch(struct rtl8169_private *tp,
 #define PHY_DELAY_MS		0xe0000000
 #define PHY_WRITE_ERI_WORD	0xf0000000
 
-static void
-rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw)
+struct fw_info {
+	u32	magic;
+	char	version[RTL_VER_SIZE];
+	__le32	fw_start;
+	__le32	fw_len;
+	u8	chksum;
+} __packed;
+
+#define FW_OPCODE_SIZE	sizeof(typeof(*((struct rtl_fw_phy_action *)0)->code))
+
+static bool rtl_fw_format_ok(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
 {
-	__le32 *phytable = (__le32 *)fw->data;
-	struct net_device *dev = tp->dev;
-	size_t index, fw_size = fw->size / sizeof(*phytable);
-	u32 predata, count;
+	const struct firmware *fw = rtl_fw->fw;
+	struct fw_info *fw_info = (struct fw_info *)fw->data;
+	struct rtl_fw_phy_action *pa = &rtl_fw->phy_action;
+	bool rc = false;
 
-	if (fw->size % sizeof(*phytable)) {
-		netif_err(tp, probe, dev, "odd sized firmware %zd\n", fw->size);
-		return;
+	if (fw->size < FW_OPCODE_SIZE)
+		goto out;
+
+	if (!fw_info->magic) {
+		size_t i, size, start;
+		u8 checksum = 0;
+
+		if (fw->size < sizeof(*fw_info))
+			goto out;
+
+		for (i = 0; i < fw->size; i++)
+			checksum += fw->data[i];
+		if (checksum != 0)
+			goto out;
+
+		start = le32_to_cpu(fw_info->fw_start);
+		if (start > fw->size)
+			goto out;
+
+		size = le32_to_cpu(fw_info->fw_len);
+		if (size > (fw->size - start) / FW_OPCODE_SIZE)
+			goto out;
+
+		memcpy(rtl_fw->version, fw_info->version, RTL_VER_SIZE);
+
+		pa->code = (__le32 *)(fw->data + start);
+		pa->size = size;
+	} else {
+		if (fw->size % FW_OPCODE_SIZE)
+			goto out;
+
+		snprintf(rtl_fw->version, RTL_VER_SIZE, "%s",
+			 rtl_lookup_firmware_name(tp));
+
+		pa->code = (__le32 *)fw->data;
+		pa->size = fw->size / FW_OPCODE_SIZE;
 	}
+	rtl_fw->version[RTL_VER_SIZE - 1] = 0;
 
-	for (index = 0; index < fw_size; index++) {
-		u32 action = le32_to_cpu(phytable[index]);
+	rc = true;
+out:
+	return rc;
+}
+
+static bool rtl_fw_data_ok(struct rtl8169_private *tp, struct net_device *dev,
+			   struct rtl_fw_phy_action *pa)
+{
+	bool rc = false;
+	size_t index;
+
+	for (index = 0; index < pa->size; index++) {
+		u32 action = le32_to_cpu(pa->code[index]);
 		u32 regno = (action & 0x0fff0000) >> 16;
 
 		switch(action & 0xf0000000) {
@@ -1771,25 +1837,25 @@ rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw)
 
 		case PHY_BJMPN:
 			if (regno > index) {
-				netif_err(tp, probe, tp->dev,
+				netif_err(tp, ifup, tp->dev,
 					  "Out of range of firmware\n");
-				return;
+				goto out;
 			}
 			break;
 		case PHY_READCOUNT_EQ_SKIP:
-			if (index + 2 >= fw_size) {
-				netif_err(tp, probe, tp->dev,
+			if (index + 2 >= pa->size) {
+				netif_err(tp, ifup, tp->dev,
 					  "Out of range of firmware\n");
-				return;
+				goto out;
 			}
 			break;
 		case PHY_COMP_EQ_SKIPN:
 		case PHY_COMP_NEQ_SKIPN:
 		case PHY_SKIPN:
-			if (index + 1 + regno >= fw_size) {
-				netif_err(tp, probe, tp->dev,
+			if (index + 1 + regno >= pa->size) {
+				netif_err(tp, ifup, tp->dev,
 					  "Out of range of firmware\n");
-				return;
+				goto out;
 			}
 			break;
 
@@ -1797,17 +1863,42 @@ rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw)
 		case PHY_WRITE_MAC_BYTE:
 		case PHY_WRITE_ERI_WORD:
 		default:
-			netif_err(tp, probe, tp->dev,
+			netif_err(tp, ifup, tp->dev,
 				  "Invalid action 0x%08x\n", action);
-			return;
+			goto out;
 		}
 	}
+	rc = true;
+out:
+	return rc;
+}
+
+static int rtl_check_firmware(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
+{
+	struct net_device *dev = tp->dev;
+	int rc = -EINVAL;
+
+	if (!rtl_fw_format_ok(tp, rtl_fw)) {
+		netif_err(tp, ifup, dev, "invalid firwmare\n");
+		goto out;
+	}
+
+	if (rtl_fw_data_ok(tp, dev, &rtl_fw->phy_action))
+		rc = 0;
+out:
+	return rc;
+}
+
+static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
+{
+	struct rtl_fw_phy_action *pa = &rtl_fw->phy_action;
+	u32 predata, count;
+	size_t index;
 
-	predata = 0;
-	count = 0;
+	predata = count = 0;
 
-	for (index = 0; index < fw_size; ) {
-		u32 action = le32_to_cpu(phytable[index]);
+	for (index = 0; index < pa->size; ) {
+		u32 action = le32_to_cpu(pa->code[index]);
 		u32 data = action & 0x0000ffff;
 		u32 regno = (action & 0x0fff0000) >> 16;
 
@@ -1879,18 +1970,20 @@ rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw)
 
 static void rtl_release_firmware(struct rtl8169_private *tp)
 {
-	if (!IS_ERR_OR_NULL(tp->fw))
-		release_firmware(tp->fw);
-	tp->fw = RTL_FIRMWARE_UNKNOWN;
+	if (!IS_ERR_OR_NULL(tp->rtl_fw)) {
+		release_firmware(tp->rtl_fw->fw);
+		kfree(tp->rtl_fw);
+	}
+	tp->rtl_fw = RTL_FIRMWARE_UNKNOWN;
 }
 
 static void rtl_apply_firmware(struct rtl8169_private *tp)
 {
-	const struct firmware *fw = tp->fw;
+	struct rtl_fw *rtl_fw = tp->rtl_fw;
 
 	/* TODO: release firmware once rtl_phy_write_fw signals failures. */
-	if (!IS_ERR_OR_NULL(fw))
-		rtl_phy_write_fw(tp, fw);
+	if (!IS_ERR_OR_NULL(rtl_fw))
+		rtl_phy_write_fw(tp, rtl_fw);
 }
 
 static void rtl_apply_firmware_cond(struct rtl8169_private *tp, u8 reg, u16 val)
@@ -3443,7 +3536,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	tp->timer.data = (unsigned long) dev;
 	tp->timer.function = rtl8169_phy_timer;
 
-	tp->fw = RTL_FIRMWARE_UNKNOWN;
+	tp->rtl_fw = RTL_FIRMWARE_UNKNOWN;
 
 	rc = register_netdev(dev);
 	if (rc < 0)
@@ -3512,25 +3605,48 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev)
 	pci_set_drvdata(pdev, NULL);
 }
 
-static void rtl_request_firmware(struct rtl8169_private *tp)
+static void rtl_request_uncached_firmware(struct rtl8169_private *tp)
 {
-	/* Return early if the firmware is already loaded / cached. */
-	if (IS_ERR(tp->fw)) {
-		const char *name;
+	struct rtl_fw *rtl_fw;
+	const char *name;
+	int rc = -ENOMEM;
 
-		name = rtl_lookup_firmware_name(tp);
-		if (name) {
-			int rc;
+	name = rtl_lookup_firmware_name(tp);
+	if (!name)
+		goto out_no_firmware;
 
-			rc = request_firmware(&tp->fw, name, &tp->pci_dev->dev);
-			if (rc >= 0)
-				return;
+	rtl_fw = kzalloc(sizeof(*rtl_fw), GFP_KERNEL);
+	if (!rtl_fw)
+		goto err_warn;
 
-			netif_warn(tp, ifup, tp->dev, "unable to load "
-				"firmware patch %s (%d)\n", name, rc);
-		}
-		tp->fw = NULL;
-	}
+	rc = request_firmware(&rtl_fw->fw, name, &tp->pci_dev->dev);
+	if (rc < 0)
+		goto err_free;
+
+	rc = rtl_check_firmware(tp, rtl_fw);
+	if (rc < 0)
+		goto err_release_firmware;
+
+	tp->rtl_fw = rtl_fw;
+out:
+	return;
+
+err_release_firmware:
+	release_firmware(rtl_fw->fw);
+err_free:
+	kfree(rtl_fw);
+err_warn:
+	netif_warn(tp, ifup, tp->dev, "unable to load firmware patch %s (%d)\n",
+		   name, rc);
+out_no_firmware:
+	tp->rtl_fw = NULL;
+	goto out;
+}
+
+static void rtl_request_firmware(struct rtl8169_private *tp)
+{
+	if (IS_ERR(tp->rtl_fw))
+		rtl_request_uncached_firmware(tp);
 }
 
 static int rtl8169_open(struct net_device *dev)
-- 
Ueimor

^ permalink raw reply related

* [PATCH net-next 1/4] r8169: move the firmware down into the device private data.
From: Francois Romieu @ 2011-06-17 19:30 UTC (permalink / raw)
  To: davem; +Cc: netdev, Realtek linux nic maintainers, Hayes Wang, Ben Hutchings
In-Reply-To: <20110617192826.GA2277@electric-eye.fr.zoreil.com>

No functional difference.

Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
---
 drivers/net/r8169.c |   74 +++++++++++++++++++++++++++++++++------------------
 1 files changed, 48 insertions(+), 26 deletions(-)

diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 7310824..3eeefe4 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -667,7 +667,9 @@ struct rtl8169_private {
 	struct rtl8169_counters counters;
 	u32 saved_wolopts;
 
-	const struct firmware *fw;
+	struct rtl_fw {
+		const struct firmware *fw;
+	} *rtl_fw;
 #define RTL_FIRMWARE_UNKNOWN	ERR_PTR(-EAGAIN);
 };
 
@@ -1222,11 +1224,12 @@ static void rtl8169_get_drvinfo(struct net_device *dev,
 				struct ethtool_drvinfo *info)
 {
 	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl_fw *rtl_fw = tp->rtl_fw;
 
 	strcpy(info->driver, MODULENAME);
 	strcpy(info->version, RTL8169_VERSION);
 	strcpy(info->bus_info, pci_name(tp->pci_dev));
-	strncpy(info->fw_version, IS_ERR_OR_NULL(tp->fw) ? "N/A" :
+	strncpy(info->fw_version, IS_ERR_OR_NULL(rtl_fw) ? "N/A" :
 		rtl_lookup_firmware_name(tp), sizeof(info->fw_version) - 1);
 }
 
@@ -1741,9 +1744,9 @@ static void rtl_writephy_batch(struct rtl8169_private *tp,
 #define PHY_DELAY_MS		0xe0000000
 #define PHY_WRITE_ERI_WORD	0xf0000000
 
-static void
-rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw)
+static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
 {
+	const struct firmware *fw = rtl_fw->fw;
 	__le32 *phytable = (__le32 *)fw->data;
 	struct net_device *dev = tp->dev;
 	size_t index, fw_size = fw->size / sizeof(*phytable);
@@ -1879,18 +1882,20 @@ rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw)
 
 static void rtl_release_firmware(struct rtl8169_private *tp)
 {
-	if (!IS_ERR_OR_NULL(tp->fw))
-		release_firmware(tp->fw);
-	tp->fw = RTL_FIRMWARE_UNKNOWN;
+	if (!IS_ERR_OR_NULL(tp->rtl_fw)) {
+		release_firmware(tp->rtl_fw->fw);
+		kfree(tp->rtl_fw);
+	}
+	tp->rtl_fw = RTL_FIRMWARE_UNKNOWN;
 }
 
 static void rtl_apply_firmware(struct rtl8169_private *tp)
 {
-	const struct firmware *fw = tp->fw;
+	struct rtl_fw *rtl_fw = tp->rtl_fw;
 
 	/* TODO: release firmware once rtl_phy_write_fw signals failures. */
-	if (!IS_ERR_OR_NULL(fw))
-		rtl_phy_write_fw(tp, fw);
+	if (!IS_ERR_OR_NULL(rtl_fw))
+		rtl_phy_write_fw(tp, rtl_fw);
 }
 
 static void rtl_apply_firmware_cond(struct rtl8169_private *tp, u8 reg, u16 val)
@@ -3443,7 +3448,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	tp->timer.data = (unsigned long) dev;
 	tp->timer.function = rtl8169_phy_timer;
 
-	tp->fw = RTL_FIRMWARE_UNKNOWN;
+	tp->rtl_fw = RTL_FIRMWARE_UNKNOWN;
 
 	rc = register_netdev(dev);
 	if (rc < 0)
@@ -3512,25 +3517,42 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev)
 	pci_set_drvdata(pdev, NULL);
 }
 
-static void rtl_request_firmware(struct rtl8169_private *tp)
+static void rtl_request_uncached_firmware(struct rtl8169_private *tp)
 {
-	/* Return early if the firmware is already loaded / cached. */
-	if (IS_ERR(tp->fw)) {
-		const char *name;
+	struct rtl_fw *rtl_fw;
+	const char *name;
+	int rc = -ENOMEM;
 
-		name = rtl_lookup_firmware_name(tp);
-		if (name) {
-			int rc;
+	name = rtl_lookup_firmware_name(tp);
+	if (!name)
+		goto out_no_firmware;
 
-			rc = request_firmware(&tp->fw, name, &tp->pci_dev->dev);
-			if (rc >= 0)
-				return;
+	rtl_fw = kzalloc(sizeof(*rtl_fw), GFP_KERNEL);
+	if (!rtl_fw)
+		goto err_warn;
 
-			netif_warn(tp, ifup, tp->dev, "unable to load "
-				"firmware patch %s (%d)\n", name, rc);
-		}
-		tp->fw = NULL;
-	}
+	rc = request_firmware(&rtl_fw->fw, name, &tp->pci_dev->dev);
+	if (rc < 0)
+		goto err_free;
+
+	tp->rtl_fw = rtl_fw;
+out:
+	return;
+
+err_free:
+	kfree(rtl_fw);
+err_warn:
+	netif_warn(tp, ifup, tp->dev, "unable to load firmware patch %s (%d)\n",
+		   name, rc);
+out_no_firmware:
+	tp->rtl_fw = NULL;
+	goto out;
+}
+
+static void rtl_request_firmware(struct rtl8169_private *tp)
+{
+	if (IS_ERR(tp->rtl_fw))
+		rtl_request_uncached_firmware(tp);
 }
 
 static int rtl8169_open(struct net_device *dev)
-- 
1.7.4.4


^ permalink raw reply related

* [PATCH net-next 2/4] r8169: explicit firmware format check.
From: Francois Romieu @ 2011-06-17 19:31 UTC (permalink / raw)
  To: davem; +Cc: netdev, Realtek linux nic maintainers, Hayes Wang, Ben Hutchings
In-Reply-To: <20110617192826.GA2277@electric-eye.fr.zoreil.com>

Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
---
 drivers/net/r8169.c |   54 +++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 42 insertions(+), 12 deletions(-)

diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 3eeefe4..452db86 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -669,6 +669,15 @@ struct rtl8169_private {
 
 	struct rtl_fw {
 		const struct firmware *fw;
+
+#define RTL_VER_SIZE		32
+
+		char version[RTL_VER_SIZE];
+
+		struct rtl_fw_phy_action {
+			__le32 *code;
+			size_t size;
+		} phy_action;
 	} *rtl_fw;
 #define RTL_FIRMWARE_UNKNOWN	ERR_PTR(-EAGAIN);
 };
@@ -1230,7 +1239,7 @@ static void rtl8169_get_drvinfo(struct net_device *dev,
 	strcpy(info->version, RTL8169_VERSION);
 	strcpy(info->bus_info, pci_name(tp->pci_dev));
 	strncpy(info->fw_version, IS_ERR_OR_NULL(rtl_fw) ? "N/A" :
-		rtl_lookup_firmware_name(tp), sizeof(info->fw_version) - 1);
+		rtl_fw->version, RTL_VER_SIZE);
 }
 
 static int rtl8169_get_regs_len(struct net_device *dev)
@@ -1744,21 +1753,42 @@ static void rtl_writephy_batch(struct rtl8169_private *tp,
 #define PHY_DELAY_MS		0xe0000000
 #define PHY_WRITE_ERI_WORD	0xf0000000
 
-static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
+#define FW_OPCODE_SIZE	sizeof(typeof(*((struct rtl_fw_phy_action *)0)->code))
+
+static bool rtl_fw_format_ok(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
 {
 	const struct firmware *fw = rtl_fw->fw;
-	__le32 *phytable = (__le32 *)fw->data;
+	struct rtl_fw_phy_action *pa = &rtl_fw->phy_action;
+	bool rc = false;
+
+	if (!(fw->size % FW_OPCODE_SIZE)) {
+		snprintf(rtl_fw->version, RTL_VER_SIZE, "%s",
+			 rtl_lookup_firmware_name(tp));
+
+		pa->code = (__le32 *)fw->data;
+		pa->size = fw->size / FW_OPCODE_SIZE;
+	}
+	rtl_fw->version[RTL_VER_SIZE - 1] = 0;
+
+	rc = true;
+
+	return rc;
+}
+
+static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
+{
+	struct rtl_fw_phy_action *pa = &rtl_fw->phy_action;
 	struct net_device *dev = tp->dev;
-	size_t index, fw_size = fw->size / sizeof(*phytable);
 	u32 predata, count;
+	size_t index;
 
-	if (fw->size % sizeof(*phytable)) {
-		netif_err(tp, probe, dev, "odd sized firmware %zd\n", fw->size);
+	if (!rtl_fw_format_ok(tp, rtl_fw)) {
+		netif_err(tp, probe, dev, "invalid firwmare\n");
 		return;
 	}
 
-	for (index = 0; index < fw_size; index++) {
-		u32 action = le32_to_cpu(phytable[index]);
+	for (index = 0; index < pa->size; index++) {
+		u32 action = le32_to_cpu(pa->code[index]);
 		u32 regno = (action & 0x0fff0000) >> 16;
 
 		switch(action & 0xf0000000) {
@@ -1780,7 +1810,7 @@ static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
 			}
 			break;
 		case PHY_READCOUNT_EQ_SKIP:
-			if (index + 2 >= fw_size) {
+			if (index + 2 >= pa->size) {
 				netif_err(tp, probe, tp->dev,
 					  "Out of range of firmware\n");
 				return;
@@ -1789,7 +1819,7 @@ static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
 		case PHY_COMP_EQ_SKIPN:
 		case PHY_COMP_NEQ_SKIPN:
 		case PHY_SKIPN:
-			if (index + 1 + regno >= fw_size) {
+			if (index + 1 + regno >= pa->size) {
 				netif_err(tp, probe, tp->dev,
 					  "Out of range of firmware\n");
 				return;
@@ -1809,8 +1839,8 @@ static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
 	predata = 0;
 	count = 0;
 
-	for (index = 0; index < fw_size; ) {
-		u32 action = le32_to_cpu(phytable[index]);
+	for (index = 0; index < pa->size; ) {
+		u32 action = le32_to_cpu(pa->code[index]);
 		u32 data = action & 0x0000ffff;
 		u32 regno = (action & 0x0fff0000) >> 16;
 
-- 
1.7.4.4


^ permalink raw reply related

* [PATCH net-next 3/4] r8169: support new firmware format.
From: Francois Romieu @ 2011-06-17 19:31 UTC (permalink / raw)
  To: davem; +Cc: netdev, Realtek linux nic maintainers, Hayes Wang, Ben Hutchings
In-Reply-To: <20110617192826.GA2277@electric-eye.fr.zoreil.com>

The new firmware format adds versioning as firmware for a specific
chipset appears to be subject to change. Current "legacy" format is
still supported.

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
---
 drivers/net/r8169.c |   43 +++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 452db86..c695c73 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -1753,15 +1753,54 @@ static void rtl_writephy_batch(struct rtl8169_private *tp,
 #define PHY_DELAY_MS		0xe0000000
 #define PHY_WRITE_ERI_WORD	0xf0000000
 
+struct fw_info {
+	u32	magic;
+	char	version[RTL_VER_SIZE];
+	__le32	fw_start;
+	__le32	fw_len;
+	u8	chksum;
+} __packed;
+
 #define FW_OPCODE_SIZE	sizeof(typeof(*((struct rtl_fw_phy_action *)0)->code))
 
 static bool rtl_fw_format_ok(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
 {
 	const struct firmware *fw = rtl_fw->fw;
+	struct fw_info *fw_info = (struct fw_info *)fw->data;
 	struct rtl_fw_phy_action *pa = &rtl_fw->phy_action;
 	bool rc = false;
 
-	if (!(fw->size % FW_OPCODE_SIZE)) {
+	if (fw->size < FW_OPCODE_SIZE)
+		goto out;
+
+	if (!fw_info->magic) {
+		size_t i, size, start;
+		u8 checksum = 0;
+
+		if (fw->size < sizeof(*fw_info))
+			goto out;
+
+		for (i = 0; i < fw->size; i++)
+			checksum += fw->data[i];
+		if (checksum != 0)
+			goto out;
+
+		start = le32_to_cpu(fw_info->fw_start);
+		if (start > fw->size)
+			goto out;
+
+		size = le32_to_cpu(fw_info->fw_len);
+		if (size > (fw->size - start) / FW_OPCODE_SIZE)
+			goto out;
+
+		memcpy(rtl_fw->version, fw_info->version, RTL_VER_SIZE);
+
+		pa->code = (__le32 *)(fw->data + start);
+		pa->size = size;
+	} else {
+		if (fw->size % FW_OPCODE_SIZE)
+			goto out;
+
 		snprintf(rtl_fw->version, RTL_VER_SIZE, "%s",
 			 rtl_lookup_firmware_name(tp));
 
@@ -1771,7 +1810,7 @@ static bool rtl_fw_format_ok(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
 	rtl_fw->version[RTL_VER_SIZE - 1] = 0;
 
 	rc = true;
-
+out:
 	return rc;
 }
 
-- 
1.7.4.4


^ permalink raw reply related

* [PATCH net-next 4/4] r8169: check firmware content sooner.
From: Francois Romieu @ 2011-06-17 19:32 UTC (permalink / raw)
  To: davem; +Cc: netdev, Realtek linux nic maintainers, Hayes Wang, Ben Hutchings
In-Reply-To: <20110617192826.GA2277@electric-eye.fr.zoreil.com>

Firmware checking is only performed when the firmware is loaded
instead of each time the driver inits the phy.

Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
---
 drivers/net/r8169.c |   63 +++++++++++++++++++++++++++++++++++---------------
 1 files changed, 44 insertions(+), 19 deletions(-)

diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index c695c73..e16929d 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -1814,18 +1814,12 @@ out:
 	return rc;
 }
 
-static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
+static bool rtl_fw_data_ok(struct rtl8169_private *tp, struct net_device *dev,
+			   struct rtl_fw_phy_action *pa)
 {
-	struct rtl_fw_phy_action *pa = &rtl_fw->phy_action;
-	struct net_device *dev = tp->dev;
-	u32 predata, count;
+	bool rc = false;
 	size_t index;
 
-	if (!rtl_fw_format_ok(tp, rtl_fw)) {
-		netif_err(tp, probe, dev, "invalid firwmare\n");
-		return;
-	}
-
 	for (index = 0; index < pa->size; index++) {
 		u32 action = le32_to_cpu(pa->code[index]);
 		u32 regno = (action & 0x0fff0000) >> 16;
@@ -1843,25 +1837,25 @@ static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
 
 		case PHY_BJMPN:
 			if (regno > index) {
-				netif_err(tp, probe, tp->dev,
+				netif_err(tp, ifup, tp->dev,
 					  "Out of range of firmware\n");
-				return;
+				goto out;
 			}
 			break;
 		case PHY_READCOUNT_EQ_SKIP:
 			if (index + 2 >= pa->size) {
-				netif_err(tp, probe, tp->dev,
+				netif_err(tp, ifup, tp->dev,
 					  "Out of range of firmware\n");
-				return;
+				goto out;
 			}
 			break;
 		case PHY_COMP_EQ_SKIPN:
 		case PHY_COMP_NEQ_SKIPN:
 		case PHY_SKIPN:
 			if (index + 1 + regno >= pa->size) {
-				netif_err(tp, probe, tp->dev,
+				netif_err(tp, ifup, tp->dev,
 					  "Out of range of firmware\n");
-				return;
+				goto out;
 			}
 			break;
 
@@ -1869,14 +1863,39 @@ static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
 		case PHY_WRITE_MAC_BYTE:
 		case PHY_WRITE_ERI_WORD:
 		default:
-			netif_err(tp, probe, tp->dev,
+			netif_err(tp, ifup, tp->dev,
 				  "Invalid action 0x%08x\n", action);
-			return;
+			goto out;
 		}
 	}
+	rc = true;
+out:
+	return rc;
+}
 
-	predata = 0;
-	count = 0;
+static int rtl_check_firmware(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
+{
+	struct net_device *dev = tp->dev;
+	int rc = -EINVAL;
+
+	if (!rtl_fw_format_ok(tp, rtl_fw)) {
+		netif_err(tp, ifup, dev, "invalid firwmare\n");
+		goto out;
+	}
+
+	if (rtl_fw_data_ok(tp, dev, &rtl_fw->phy_action))
+		rc = 0;
+out:
+	return rc;
+}
+
+static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
+{
+	struct rtl_fw_phy_action *pa = &rtl_fw->phy_action;
+	u32 predata, count;
+	size_t index;
+
+	predata = count = 0;
 
 	for (index = 0; index < pa->size; ) {
 		u32 action = le32_to_cpu(pa->code[index]);
@@ -3604,10 +3623,16 @@ static void rtl_request_uncached_firmware(struct rtl8169_private *tp)
 	if (rc < 0)
 		goto err_free;
 
+	rc = rtl_check_firmware(tp, rtl_fw);
+	if (rc < 0)
+		goto err_release_firmware;
+
 	tp->rtl_fw = rtl_fw;
 out:
 	return;
 
+err_release_firmware:
+	release_firmware(rtl_fw->fw);
 err_free:
 	kfree(rtl_fw);
 err_warn:
-- 
1.7.4.4


^ permalink raw reply related

* Re: [PATCH 0/2] Allow NICs to pass Frame Checksum up the stack.
From: Michał Mirosław @ 2011-06-17 20:00 UTC (permalink / raw)
  To: greearb; +Cc: netdev
In-Reply-To: <1308339615-5866-1-git-send-email-greearb@candelatech.com>

2011/6/17  <greearb@candelatech.com>:
> From: Ben Greear <greearb@candelatech.com>
>
> This series provides ethtool support to set and get the rx-checksum
> flag, and adds support to the e100 driver.
[...]

If you want to test the new features approach, you can shave top bit
off NETIF_F_GSO_MASK (there are two unused bits there). The
introducing patch will be +2 lines (+1 dev.c, +1 ethtool.c),
implementation in e100: 20 lines less than patch you sent, ethtool
userspace changes: none (assuming
http://patchwork.ozlabs.org/patch/96374/ or equivalent applied).

Best Regards,
Michał Mirosław

^ permalink raw reply

* what's causing "ip_rt_bug"?
From: Tomasz Chmielewski @ 2011-06-17 20:00 UTC (permalink / raw)
  To: netdev

I have a system pushing around 800 Mbit/s, ~130 kpps.

It uses 2.6.35.12 kernel.


Several times a minute, I can see entries like (a.b.c.d - IP of this system):

Jun 18 02:39:19 KOR-SV22 kernel: [37187.665951] ip_rt_bug: 110.x.x.x -> a.b.c.d, ?
Jun 18 02:39:19 KOR-SV22 kernel: [37187.685419] ip_rt_bug: 110.x.x.x -> a.b.c.d, ?
Jun 18 02:40:31 KOR-SV22 kernel: [37259.199315] ip_rt_bug: 124.x.x.x -> a.b.c.d, ?
Jun 18 02:40:36 KOR-SV22 kernel: [37263.828000] ip_rt_bug: 124.x.x.x -> a.b.c.d, ?
Jun 18 02:44:16 KOR-SV22 kernel: [37484.120689] ip_rt_bug: 110.x.x.x -> a.b.c.d, ?
Jun 18 02:44:19 KOR-SV22 kernel: [37487.114357] ip_rt_bug: 110.x.x.x -> a.b.c.d, ?

What may be causing this? Is it "dangerous"?


-- 
Tomasz Chmielewski
http://wpkg.org

^ permalink raw reply

* [PATCH] inet_diag: fix inet_diag_bc_audit()
From: Eric Dumazet @ 2011-06-17 20:19 UTC (permalink / raw)
  To: Eugene Teo
  Cc: Dan Rosenberg, davem, kuznet, netdev, security,
	Arnaldo Carvalho de Melo, Stephen Hemminger
In-Reply-To: <BANLkTin9fqYSxq4ne5hV_ri-zKeMZ9mE_g@mail.gmail.com>

Le vendredi 03 juin 2011 à 14:55 +0800, Eugene Teo a écrit :
> Cc'ed acme.
> 
> On Wed, Jun 1, 2011 at 11:40 PM, Dan Rosenberg <drosenberg@vsecurity.com> wrote:
> > It seems to me that the auditing performed by inet_diag_bc_audit() is
> > insufficient to prevent pathological INET_DIAG bytecode from doing bad
> > things.
> >
> > Firstly, it's possible to cause an infinite loop in inet_diag_bc_audit()
> > with a INET_DIAG_BC_JMP opcode with a "yes" value of 0.  The valid_cc()
> > function, also called from here, seems suspicious as well.
> >
> > Once the bytecode is actually run in inet_diag_bc_run(), it looks like
> > more infinite loops are possible, if appropriate "yes" or "no" values
> > are set to zero and weren't validated by the audit.
> >
> > Finally, I can't seem to find any validation that the reported length of
> > the netlink message header doesn't exceed the skb length, as checked in
> > some other netlink receive functions, which could result in reading
> > beyond the bounds of the socket data.  I could just be missing something
> > here though.
> >
> > Regards,
> > Dan
> >

Thanks guys, here is the patch I cooked to address this problem, sorry
for the long delay again.

[PATCH] inet_diag: fix inet_diag_bc_audit()

A malicious user or buggy application can inject code and trigger an
infinite loop in inet_diag_bc_audit()

Also make sure each instruction is aligned on 4 bytes boundary, to avoid
unaligned accesses.

Reported-by: Dan Rosenberg <drosenberg@vsecurity.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Arnaldo Carvalho de Melo <acme@infradead.org>
CC: Eugene Teo <eugeneteo@kernel.sg>
CC: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
---
 net/ipv4/inet_diag.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 6ffe94c..3267d38 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -437,7 +437,7 @@ static int valid_cc(const void *bc, int len, int cc)
 			return 0;
 		if (cc == len)
 			return 1;
-		if (op->yes < 4)
+		if (op->yes < 4 || op->yes & 3)
 			return 0;
 		len -= op->yes;
 		bc  += op->yes;
@@ -447,11 +447,11 @@ static int valid_cc(const void *bc, int len, int cc)
 
 static int inet_diag_bc_audit(const void *bytecode, int bytecode_len)
 {
-	const unsigned char *bc = bytecode;
+	const void *bc = bytecode;
 	int  len = bytecode_len;
 
 	while (len > 0) {
-		struct inet_diag_bc_op *op = (struct inet_diag_bc_op *)bc;
+		const struct inet_diag_bc_op *op = bc;
 
 //printk("BC: %d %d %d {%d} / %d\n", op->code, op->yes, op->no, op[1].no, len);
 		switch (op->code) {
@@ -462,22 +462,20 @@ static int inet_diag_bc_audit(const void *bytecode, int bytecode_len)
 		case INET_DIAG_BC_S_LE:
 		case INET_DIAG_BC_D_GE:
 		case INET_DIAG_BC_D_LE:
-			if (op->yes < 4 || op->yes > len + 4)
-				return -EINVAL;
 		case INET_DIAG_BC_JMP:
-			if (op->no < 4 || op->no > len + 4)
+			if (op->no < 4 || op->no > len + 4 || op->no & 3)
 				return -EINVAL;
 			if (op->no < len &&
 			    !valid_cc(bytecode, bytecode_len, len - op->no))
 				return -EINVAL;
 			break;
 		case INET_DIAG_BC_NOP:
-			if (op->yes < 4 || op->yes > len + 4)
-				return -EINVAL;
 			break;
 		default:
 			return -EINVAL;
 		}
+		if (op->yes < 4 || op->yes > len + 4 || op->yes & 3)
+			return -EINVAL;
 		bc  += op->yes;
 		len -= op->yes;
 	}



^ permalink raw reply related

* Re: [PATCH] inet_diag: fix inet_diag_bc_audit()
From: David Miller @ 2011-06-17 20:26 UTC (permalink / raw)
  To: eric.dumazet
  Cc: eugeneteo, drosenberg, kuznet, netdev, security, acme, shemminger
In-Reply-To: <1308341990.3539.27.camel@edumazet-laptop>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 17 Jun 2011 22:19:50 +0200

> [PATCH] inet_diag: fix inet_diag_bc_audit()
> 
> A malicious user or buggy application can inject code and trigger an
> infinite loop in inet_diag_bc_audit()
> 
> Also make sure each instruction is aligned on 4 bytes boundary, to avoid
> unaligned accesses.
> 
> Reported-by: Dan Rosenberg <drosenberg@vsecurity.com>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>

Applied and queued up for -stable, thanks!

^ permalink raw reply

* Re: what's causing "ip_rt_bug"?
From: Eric Dumazet @ 2011-06-17 20:36 UTC (permalink / raw)
  To: Tomasz Chmielewski; +Cc: netdev
In-Reply-To: <4DFBB270.8000003@wpkg.org>

Le vendredi 17 juin 2011 à 22:00 +0200, Tomasz Chmielewski a écrit :
> I have a system pushing around 800 Mbit/s, ~130 kpps.
> 
> It uses 2.6.35.12 kernel.
> 
> 
> Several times a minute, I can see entries like (a.b.c.d - IP of this system):
> 
> Jun 18 02:39:19 KOR-SV22 kernel: [37187.665951] ip_rt_bug: 110.x.x.x -> a.b.c.d, ?
> Jun 18 02:39:19 KOR-SV22 kernel: [37187.685419] ip_rt_bug: 110.x.x.x -> a.b.c.d, ?
> Jun 18 02:40:31 KOR-SV22 kernel: [37259.199315] ip_rt_bug: 124.x.x.x -> a.b.c.d, ?
> Jun 18 02:40:36 KOR-SV22 kernel: [37263.828000] ip_rt_bug: 124.x.x.x -> a.b.c.d, ?
> Jun 18 02:44:16 KOR-SV22 kernel: [37484.120689] ip_rt_bug: 110.x.x.x -> a.b.c.d, ?
> Jun 18 02:44:19 KOR-SV22 kernel: [37487.114357] ip_rt_bug: 110.x.x.x -> a.b.c.d, ?
> 

Hi

What your routing table looks like ? (ip ro)

You also could backport this patch so that we can catch where/why this
happens

commit c378a9c019cf5e017d1ed24954b54fae7bebd2bc
Author: Dave Jones <davej@redhat.com>
Date:   Sat May 21 07:16:42 2011 +0000

    ipv4: Give backtrace in ip_rt_bug().
    
    Add a stack backtrace to the ip_rt_bug path for debugging
    
    Signed-off-by: Dave Jones <davej@redhat.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index b24d58e..52b0b95 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1665,6 +1665,7 @@ static int ip_rt_bug(struct sk_buff *skb)
 		&ip_hdr(skb)->saddr, &ip_hdr(skb)->daddr,
 		skb->dev ? skb->dev->name : "?");
 	kfree_skb(skb);
+	WARN_ON(1);
 	return 0;
 }
 




^ permalink raw reply related

* Re: [PATCH 0/2] Allow NICs to pass Frame Checksum up the stack.
From: Ben Greear @ 2011-06-17 20:48 UTC (permalink / raw)
  To: Michał Mirosław; +Cc: netdev
In-Reply-To: <BANLkTikiNT1F39XaMFWc67OuP=StmntL=g@mail.gmail.com>

On 06/17/2011 01:00 PM, Michał Mirosław wrote:
> 2011/6/17<greearb@candelatech.com>:
>> From: Ben Greear<greearb@candelatech.com>
>>
>> This series provides ethtool support to set and get the rx-checksum
>> flag, and adds support to the e100 driver.
> [...]
>
> If you want to test the new features approach, you can shave top bit
> off NETIF_F_GSO_MASK (there are two unused bits there). The
> introducing patch will be +2 lines (+1 dev.c, +1 ethtool.c),
> implementation in e100: 20 lines less than patch you sent, ethtool
> userspace changes: none (assuming
> http://patchwork.ozlabs.org/patch/96374/ or equivalent applied).

Well, is that patch going in?

How do we get more bits if we need more than two?  Totally new
API?

Thanks,
Ben

>
> Best Regards,
> Michał Mirosław


-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


^ permalink raw reply

* Re: [PATCH 0/2] Allow NICs to pass Frame Checksum up the stack.
From: Ben Hutchings @ 2011-06-17 20:57 UTC (permalink / raw)
  To: Ben Greear; +Cc: Michał Mirosław, netdev
In-Reply-To: <4DFBBD83.9040300@candelatech.com>

On Fri, 2011-06-17 at 13:48 -0700, Ben Greear wrote:
> On 06/17/2011 01:00 PM, Michał Mirosław wrote:
> > 2011/6/17<greearb@candelatech.com>:
> >> From: Ben Greear<greearb@candelatech.com>
> >>
> >> This series provides ethtool support to set and get the rx-checksum
> >> flag, and adds support to the e100 driver.
> > [...]
> >
> > If you want to test the new features approach, you can shave top bit
> > off NETIF_F_GSO_MASK (there are two unused bits there). The
> > introducing patch will be +2 lines (+1 dev.c, +1 ethtool.c),
> > implementation in e100: 20 lines less than patch you sent, ethtool
> > userspace changes: none (assuming
> > http://patchwork.ozlabs.org/patch/96374/ or equivalent applied).
> 
> Well, is that patch going in?
> 
> How do we get more bits if we need more than two?  Totally new
> API?

See this thread:
http://thread.gmane.org/gmane.linux.network/196684

Ben.

-- 
Ben Hutchings, Senior Software 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 0/2] Allow NICs to pass Frame Checksum up the stack.
From: Ben Greear @ 2011-06-17 20:58 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: Michał Mirosław, netdev
In-Reply-To: <1308344222.2831.20.camel@bwh-desktop>

On 06/17/2011 01:57 PM, Ben Hutchings wrote:
> On Fri, 2011-06-17 at 13:48 -0700, Ben Greear wrote:
>> On 06/17/2011 01:00 PM, Michał Mirosław wrote:
>>> 2011/6/17<greearb@candelatech.com>:
>>>> From: Ben Greear<greearb@candelatech.com>
>>>>
>>>> This series provides ethtool support to set and get the rx-checksum
>>>> flag, and adds support to the e100 driver.
>>> [...]
>>>
>>> If you want to test the new features approach, you can shave top bit
>>> off NETIF_F_GSO_MASK (there are two unused bits there). The
>>> introducing patch will be +2 lines (+1 dev.c, +1 ethtool.c),
>>> implementation in e100: 20 lines less than patch you sent, ethtool
>>> userspace changes: none (assuming
>>> http://patchwork.ozlabs.org/patch/96374/ or equivalent applied).
>>
>> Well, is that patch going in?
>>
>> How do we get more bits if we need more than two?  Totally new
>> API?
>
> See this thread:
> http://thread.gmane.org/gmane.linux.network/196684

It's idle for 11 days.  Seems dead in the water if you ask me.

Thanks,
Ben

>
> Ben.
>


-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


^ permalink raw reply

* Re: [PATCH net-next 2/4] r8169: explicit firmware format check.
From: Ben Hutchings @ 2011-06-17 21:13 UTC (permalink / raw)
  To: Francois Romieu
  Cc: davem, netdev, Realtek linux nic maintainers, Hayes Wang,
	Ben Hutchings
In-Reply-To: <20110617193105.GB2287@electric-eye.fr.zoreil.com>

On Fri, 2011-06-17 at 21:31 +0200, Francois Romieu wrote:
> Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
> ---
>  drivers/net/r8169.c |   54 +++++++++++++++++++++++++++++++++++++++-----------
>  1 files changed, 42 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
> index 3eeefe4..452db86 100644
> --- a/drivers/net/r8169.c
> +++ b/drivers/net/r8169.c
> @@ -669,6 +669,15 @@ struct rtl8169_private {
>  
>  	struct rtl_fw {
>  		const struct firmware *fw;
> +
> +#define RTL_VER_SIZE		32
> +
> +		char version[RTL_VER_SIZE];
> +
> +		struct rtl_fw_phy_action {
> +			__le32 *code;
> +			size_t size;
> +		} phy_action;
>  	} *rtl_fw;
>  #define RTL_FIRMWARE_UNKNOWN	ERR_PTR(-EAGAIN);
>  };
> @@ -1230,7 +1239,7 @@ static void rtl8169_get_drvinfo(struct net_device *dev,
>  	strcpy(info->version, RTL8169_VERSION);
>  	strcpy(info->bus_info, pci_name(tp->pci_dev));
>  	strncpy(info->fw_version, IS_ERR_OR_NULL(rtl_fw) ? "N/A" :
> -		rtl_lookup_firmware_name(tp), sizeof(info->fw_version) - 1);
> +		rtl_fw->version, RTL_VER_SIZE);

You appear to ensure that rtl_fw->version is properly terminated, so I
would suggest:

	BUILD_BUG_ON(sizeof(info->fw_version) < sizeof(rtl_fw->version));
	strcpy(info->fw_version, IS_ERR_OR_NULL(rtl_fw) ? "N/A" : rtl_fw->version);

>  }
>  
>  static int rtl8169_get_regs_len(struct net_device *dev)
> @@ -1744,21 +1753,42 @@ static void rtl_writephy_batch(struct rtl8169_private *tp,
>  #define PHY_DELAY_MS		0xe0000000
>  #define PHY_WRITE_ERI_WORD	0xf0000000
>  
> -static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
> +#define FW_OPCODE_SIZE	sizeof(typeof(*((struct rtl_fw_phy_action *)0)->code))
> +
> +static bool rtl_fw_format_ok(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
>  {
>  	const struct firmware *fw = rtl_fw->fw;
> -	__le32 *phytable = (__le32 *)fw->data;
> +	struct rtl_fw_phy_action *pa = &rtl_fw->phy_action;
> +	bool rc = false;
> +
> +	if (!(fw->size % FW_OPCODE_SIZE)) {
> +		snprintf(rtl_fw->version, RTL_VER_SIZE, "%s",
> +			 rtl_lookup_firmware_name(tp));

strlcpy()

> +		pa->code = (__le32 *)fw->data;
> +		pa->size = fw->size / FW_OPCODE_SIZE;
> +	}
> +	rtl_fw->version[RTL_VER_SIZE - 1] = 0;
> +
> +	rc = true;
> +
> +	return rc;
> +}
[...]

This function is doing rather more than what its name suggests.  And it
always returns true, so it doesn't actually do what its name suggests at
all.

Ben.

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

* [PATCH 1/1] r8169: fix static initializers.
From: Francois Romieu @ 2011-06-17 21:01 UTC (permalink / raw)
  To: davem; +Cc: netdev, Realtek linux nic maintainers, Hayes Wang

Please pull from branch 'davem.r8169' in repository

git://git.kernel.org/pub/scm/linux/kernel/git/romieu/netdev-2.6.git davem.r8169

to get the change below.

Distance from 'davem' (eeb1497277d6b1a0a34ed36b97e18f2bd7d6de0d)
----------------------------------------------------------------

3744100e05c4e403ed21c99cd389c7e784664e4b

Diffstat
--------

 drivers/net/r8169.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

Shortlog
--------

Francois Romieu (1):
      r8169: fix static initializers.

Patch
-----

diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index ef1ce2e..05d8178 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -1621,7 +1621,7 @@ static void rtl8169_get_mac_version(struct rtl8169_private *tp,
 	 *
 	 * (RTL_R32(TxConfig) & 0x700000) == 0x200000 ? 8101Eb : 8101Ec
 	 */
-	static const struct {
+	static const struct rtl_mac_info {
 		u32 mask;
 		u32 val;
 		int mac_version;
@@ -1689,7 +1689,8 @@ static void rtl8169_get_mac_version(struct rtl8169_private *tp,
 
 		/* Catch-all */
 		{ 0x00000000, 0x00000000,	RTL_GIGA_MAC_NONE   }
-	}, *p = mac_info;
+	};
+	const struct rtl_mac_info *p = mac_info;
 	u32 reg;
 
 	reg = RTL_R32(TxConfig);
@@ -3681,7 +3682,7 @@ static void rtl_set_rx_max_size(void __iomem *ioaddr, unsigned int rx_buf_sz)
 
 static void rtl8169_set_magic_reg(void __iomem *ioaddr, unsigned mac_version)
 {
-	static const struct {
+	static const struct rtl_cfg2_info {
 		u32 mac_version;
 		u32 clk;
 		u32 val;
@@ -3690,7 +3691,8 @@ static void rtl8169_set_magic_reg(void __iomem *ioaddr, unsigned mac_version)
 		{ RTL_GIGA_MAC_VER_05, PCI_Clock_66MHz, 0x000fffff },
 		{ RTL_GIGA_MAC_VER_06, PCI_Clock_33MHz, 0x00ffff00 }, // 8110SCe
 		{ RTL_GIGA_MAC_VER_06, PCI_Clock_66MHz, 0x00ffffff }
-	}, *p = cfg2_info;
+	};
+	const struct rtl_cfg2_info *p = cfg2_info;
 	unsigned int i;
 	u32 clk;
 
-- 
Ueimor

^ permalink raw reply related

* [PATCH 0/7] Series short description
From: John Fastabend @ 2011-06-17 21:08 UTC (permalink / raw)
  To: davem; +Cc: netdev, shmulikr

The following series implements...

---

John Fastabend (7):
      dcb: Add missing error check in dcb_ieee_set()
      dcb: fix return type on dcb_setapp()
      dcb: Add dcb_ieee_getapp_mask() for drivers to query APP settings
      dcb: Add ieee_dcb_delapp() and dcb op to delete app entry
      dcbnl: Add ieee_dcb_setapp() to be used for IEEE 802.1Qaz APP data
      net: dcbnl, add multicast group for DCB
      Add DCBX capabilities bitmask to the get_ieee response.


 include/linux/dcbnl.h     |    2 
 include/linux/rtnetlink.h |    2 
 include/net/dcbnl.h       |    6 +
 net/dcb/dcbnl.c           |  414 +++++++++++++++++++++++++++++++++++----------
 4 files changed, 334 insertions(+), 90 deletions(-)

-- 
Signature

^ permalink raw reply

* Re: [PATCH net-next 3/4] r8169: support new firmware format.
From: Ben Hutchings @ 2011-06-17 21:15 UTC (permalink / raw)
  To: Francois Romieu
  Cc: davem, netdev, Realtek linux nic maintainers, Hayes Wang,
	Ben Hutchings
In-Reply-To: <20110617193133.GC2287@electric-eye.fr.zoreil.com>

On Fri, 2011-06-17 at 21:31 +0200, Francois Romieu wrote:
> The new firmware format adds versioning as firmware for a specific
> chipset appears to be subject to change. Current "legacy" format is
> still supported.
[...]
>  static bool rtl_fw_format_ok(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
>  {
[...] 
> -	if (!(fw->size % FW_OPCODE_SIZE)) {
> +	if (fw->size < FW_OPCODE_SIZE)
> +		goto out;
[...]
> +		if (fw->size % FW_OPCODE_SIZE)
> +			goto out;
> +
[...]
> -
> +out:
>  	return rc;
>  }

These changes belong in patch 2/4.

Ben.

-- 
Ben Hutchings, Senior Software 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 net-next 2/4] r8169: explicit firmware format check.
From: Ben Hutchings @ 2011-06-17 21:16 UTC (permalink / raw)
  To: Francois Romieu
  Cc: davem, netdev, Realtek linux nic maintainers, Hayes Wang,
	Ben Hutchings
In-Reply-To: <20110617193105.GB2287@electric-eye.fr.zoreil.com>

On Fri, 2011-06-17 at 21:31 +0200, Francois Romieu wrote:
[...]
> -	if (fw->size % sizeof(*phytable)) {
> -		netif_err(tp, probe, dev, "odd sized firmware %zd\n", fw->size);
> +	if (!rtl_fw_format_ok(tp, rtl_fw)) {
> +		netif_err(tp, probe, dev, "invalid firwmare\n");
[...]

Also, there's a typo in this error message.

Ben.

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

* [PATCH 0/7] Series short description
From: John Fastabend @ 2011-06-17 21:16 UTC (permalink / raw)
  To: davem; +Cc: netdev, shmulikr

The following series implements improvements to the DCB netlink
interface. This work was done to improve Application handling
and support firmware based LLDP agents.

This adds a multicast group for DCB currently user space has
trouble keeping in sync across multiple applications and with
firmware agents making DCB attribute changes in the driver.

To help support the recently ratified IEEE802.1Qaz extension
which supports multiple APP data entries for the same
selector and protocol fields a series of ieee set and delete
routines were improved and in the delete case added.

Finally the patches 5 and 6 are fixes to currently existing
code.

Please consider for net-next-2.6 inclusion.

---

John Fastabend (7):
      dcb: Add missing error check in dcb_ieee_set()
      dcb: fix return type on dcb_setapp()
      dcb: Add dcb_ieee_getapp_mask() for drivers to query APP settings
      dcb: Add ieee_dcb_delapp() and dcb op to delete app entry
      dcb: Add ieee_dcb_setapp() to be used for IEEE 802.1Qaz APP data
      net: dcbnl, add multicast group for DCB
      dcb: Add DCBX capabilities bitmask to the get_ieee response


 include/linux/dcbnl.h     |    2 
 include/linux/rtnetlink.h |    2 
 include/net/dcbnl.h       |    6 +
 net/dcb/dcbnl.c           |  414 +++++++++++++++++++++++++++++++++++----------
 4 files changed, 334 insertions(+), 90 deletions(-)

-- 
Signature

^ 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