Re: [PATCH v2] cgroup: net_cls: fix false-positive "suspicious RCU usage"

2015-07-25 Thread David Miller
From: Konstantin Khlebnikov 
Date: Wed, 22 Jul 2015 12:23:20 +0300

> In dev_queue_xmit() net_cls protected with rcu-bh.
 ...
> Signed-off-by: Konstantin Khlebnikov 

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [net-next 00/15][pull request] Intel Wired LAN Driver Updates 2015-07-23

2015-07-25 Thread David Miller
From: Jeff Kirsher 
Date: Thu, 23 Jul 2015 06:52:29 -0700

> This series contains updates to e1000e, igb, ixgbevf, i40e and i40evf.

Pulled, thanks Jeff.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 00/10] Netfilter/IPVS fixes for net

2015-07-25 Thread David Miller
From: Pablo Neira Ayuso 
Date: Thu, 23 Jul 2015 01:00:42 +0200

> The following patchset contains ten Netfilter/IPVS fixes, they are:

Pulled, thanks a lot Pablo.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH iproute2] xfrm: remove duplicated include

2015-07-25 Thread Zhang Shengju
Remove dupldated include for , since it's already
included by 'xfrm.h'.

Signed-off-by: Zhang Shengju 
---
 ip/ipxfrm.c   | 1 -
 ip/xfrm_monitor.c | 1 -
 ip/xfrm_policy.c  | 1 -
 ip/xfrm_state.c   | 1 -
 4 files changed, 4 deletions(-)

diff --git a/ip/ipxfrm.c b/ip/ipxfrm.c
index 9c26428..e583abf 100644
--- a/ip/ipxfrm.c
+++ b/ip/ipxfrm.c
@@ -34,7 +34,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "utils.h"
 #include "xfrm.h"
diff --git a/ip/xfrm_monitor.c b/ip/xfrm_monitor.c
index ebccb71..8b21efa 100644
--- a/ip/xfrm_monitor.c
+++ b/ip/xfrm_monitor.c
@@ -28,7 +28,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "utils.h"
 #include "xfrm.h"
diff --git a/ip/xfrm_policy.c b/ip/xfrm_policy.c
index 8f4d1a0..efea1e8 100644
--- a/ip/xfrm_policy.c
+++ b/ip/xfrm_policy.c
@@ -29,7 +29,6 @@
 #include 
 #include 
 #include 
-#include 
 #include "utils.h"
 #include "xfrm.h"
 #include "ip_common.h"
diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c
index d2831d0..b5734da 100644
--- a/ip/xfrm_state.c
+++ b/ip/xfrm_state.c
@@ -28,7 +28,6 @@
 #include 
 #include 
 #include 
-#include 
 #include "utils.h"
 #include "xfrm.h"
 #include "ip_common.h"
-- 
1.8.3.1



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] e1000e: Move e1000e_disable_aspm_locked() inside CONFIG_PM

2015-07-25 Thread Michael Ellerman
On Thu, 2015-07-23 at 07:07 -0700, Jeff Kirsher wrote:
> On Wed, 2015-07-22 at 11:41 +1000, Michael Ellerman wrote:
> > On Wed, 2015-07-15 at 03:30 -0700, Jeff Kirsher wrote:
> > > On Tue, 2015-07-14 at 13:54 +1000, Michael Ellerman wrote:
> > > > e1000e_disable_aspm_locked() is only used in __e1000_resume()
> > which is
> > > > inside CONFIG_PM. So when CONFIG_PM=n we get a "defined but not
> > used"
> > > > warning for e1000e_disable_aspm_locked().
> > > > 
> > > > Move it inside the existing CONFIG_PM block to avoid the warning.
> > > > 
> > > > Signed-off-by: Michael Ellerman 
> > > > ---
> > > >  drivers/net/ethernet/intel/e1000e/netdev.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > NACK, this is already fixed in my next-queue tree.  Raanan submitted
> > a
> > > patch back on July 6th to resolve this issue, see commit id
> > > a75787d2246a93d256061db602f252703559af65 in my dev-queue branch of
> > my
> > > next-queue tree.
> > 
> > OK. I take it your next-queue is destined for 4.3, so we'll just have
> > to suck
> > on the warning until then?
> 
> Yes, but I can queue Raanan's patch up for 4.2 (and possibly stable) if
> necessary.  I have no issue with doing that.

For 4.2 would be nice, it would make my builds green again. But it's not the
end of the world if it has to wait until 4.3.

cheers


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH iproute2] ip: replace white-spaces with tabs

2015-07-25 Thread Zhang Shengju
Replace white-spaces with tabs

Signed-off-by: Zhang Shengju 
---
 ip/ip.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/ip/ip.c b/ip/ip.c
index c23de74..78134f9 100644
--- a/ip/ip.c
+++ b/ip/ip.c
@@ -64,7 +64,7 @@ static void usage(void)
 static int do_help(int argc, char **argv)
 {
usage();
-return 0;
+   return 0;
 }
 
 static const struct cmd {
@@ -185,8 +185,8 @@ int main(int argc, char **argv)
argv++;
if (argc <= 1)
usage();
-max_flush_loops = atoi(argv[1]);
-} else if (matches(opt, "-family") == 0) {
+   max_flush_loops = atoi(argv[1]);
+   } else if (matches(opt, "-family") == 0) {
argc--;
argv++;
if (argc <= 1)
-- 
1.8.3.1



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next] bonding: convert num_grat_arp to the new bonding option API

2015-07-25 Thread Veaceslav Falico

On Fri, Jul 24, 2015 at 03:50:31PM +0200, Nikolay Aleksandrov wrote:

From: Nikolay Aleksandrov 

num_grat_arp wasn't converted to the new bonding option API, so do this
now and remove the specific sysfs store option in order to use the
standard one. num_grat_arp is the same as num_unsol_na so add it as an
alias with the same option settings. An important difference is the option
name which is matched in bond_sysfs_store_option().

Signed-off-by: Nikolay Aleksandrov 


Acked-by: Veaceslav Falico 


---
drivers/net/bonding/bond_options.c |  7 +++
drivers/net/bonding/bond_sysfs.c   | 20 +++-
include/net/bond_options.h |  1 +
3 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/net/bonding/bond_options.c 
b/drivers/net/bonding/bond_options.c
index e9c624d54dd4..6dda57e2e724 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -420,6 +420,13 @@ static const struct bond_option bond_opts[BOND_OPT_LAST] = 
{
.flags = BOND_OPTFLAG_IFDOWN,
.values = bond_ad_user_port_key_tbl,
.set = bond_option_ad_user_port_key_set,
+   },
+   [BOND_OPT_NUM_PEER_NOTIF_ALIAS] = {
+   .id = BOND_OPT_NUM_PEER_NOTIF_ALIAS,
+   .name = "num_grat_arp",
+   .desc = "Number of peer notifications to send on failover 
event",
+   .values = bond_num_peer_notif_tbl,
+   .set = bond_option_num_peer_notif_set
}
};

diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 31835a4dab57..f4ae72086215 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -380,7 +380,7 @@ static ssize_t bonding_show_ad_select(struct device *d,
static DEVICE_ATTR(ad_select, S_IRUGO | S_IWUSR,
   bonding_show_ad_select, bonding_sysfs_store_option);

-/* Show and set the number of peer notifications to send after a failover 
event. */
+/* Show the number of peer notifications to send after a failover event. */
static ssize_t bonding_show_num_peer_notif(struct device *d,
   struct device_attribute *attr,
   char *buf)
@@ -388,24 +388,10 @@ static ssize_t bonding_show_num_peer_notif(struct device 
*d,
struct bonding *bond = to_bond(d);
return sprintf(buf, "%d\n", bond->params.num_peer_notif);
}
-
-static ssize_t bonding_store_num_peer_notif(struct device *d,
-   struct device_attribute *attr,
-   const char *buf, size_t count)
-{
-   struct bonding *bond = to_bond(d);
-   int ret;
-
-   ret = bond_opt_tryset_rtnl(bond, BOND_OPT_NUM_PEER_NOTIF, (char *)buf);
-   if (!ret)
-   ret = count;
-
-   return ret;
-}
static DEVICE_ATTR(num_grat_arp, S_IRUGO | S_IWUSR,
-  bonding_show_num_peer_notif, bonding_store_num_peer_notif);
+  bonding_show_num_peer_notif, bonding_sysfs_store_option);
static DEVICE_ATTR(num_unsol_na, S_IRUGO | S_IWUSR,
-  bonding_show_num_peer_notif, bonding_store_num_peer_notif);
+  bonding_show_num_peer_notif, bonding_sysfs_store_option);

/* Show the MII monitor interval. */
static ssize_t bonding_show_miimon(struct device *d,
diff --git a/include/net/bond_options.h b/include/net/bond_options.h
index c28aca25320e..1797235cd590 100644
--- a/include/net/bond_options.h
+++ b/include/net/bond_options.h
@@ -66,6 +66,7 @@ enum {
BOND_OPT_AD_ACTOR_SYS_PRIO,
BOND_OPT_AD_ACTOR_SYSTEM,
BOND_OPT_AD_USER_PORT_KEY,
+   BOND_OPT_NUM_PEER_NOTIF_ALIAS,
BOND_OPT_LAST
};

--
2.4.3


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] dsa: mv88e6352/mv88e6xxx: Move temperature sensor code to mv88e6xxx.c

2015-07-25 Thread Guenter Roeck
Move the temperature sensing code for mv88e6352 and mv88e6320 families
into mv88e6xxx.c to simplify adding support for additional chips.

With this change, mv88e6xxx_6320_family() no longer needs to be
a global function and is made static.

Cc: Andrew Lunn 
Signed-off-by: Guenter Roeck 
---
 drivers/net/dsa/mv88e6352.c |  72 +-
 drivers/net/dsa/mv88e6xxx.c | 176 
 drivers/net/dsa/mv88e6xxx.h |   7 +-
 3 files changed, 136 insertions(+), 119 deletions(-)

diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
index cfece5ae9d5f..af210efecc55 100644
--- a/drivers/net/dsa/mv88e6352.c
+++ b/drivers/net/dsa/mv88e6352.c
@@ -92,70 +92,6 @@ static int mv88e6352_setup_global(struct dsa_switch *ds)
return 0;
 }
 
-#ifdef CONFIG_NET_DSA_HWMON
-
-static int mv88e6352_get_temp(struct dsa_switch *ds, int *temp)
-{
-   int phy = mv88e6xxx_6320_family(ds) ? 3 : 0;
-   int ret;
-
-   *temp = 0;
-
-   ret = mv88e6xxx_phy_page_read(ds, phy, 6, 27);
-   if (ret < 0)
-   return ret;
-
-   *temp = (ret & 0xff) - 25;
-
-   return 0;
-}
-
-static int mv88e6352_get_temp_limit(struct dsa_switch *ds, int *temp)
-{
-   int phy = mv88e6xxx_6320_family(ds) ? 3 : 0;
-   int ret;
-
-   *temp = 0;
-
-   ret = mv88e6xxx_phy_page_read(ds, phy, 6, 26);
-   if (ret < 0)
-   return ret;
-
-   *temp = (((ret >> 8) & 0x1f) * 5) - 25;
-
-   return 0;
-}
-
-static int mv88e6352_set_temp_limit(struct dsa_switch *ds, int temp)
-{
-   int phy = mv88e6xxx_6320_family(ds) ? 3 : 0;
-   int ret;
-
-   ret = mv88e6xxx_phy_page_read(ds, phy, 6, 26);
-   if (ret < 0)
-   return ret;
-   temp = clamp_val(DIV_ROUND_CLOSEST(temp, 5) + 5, 0, 0x1f);
-   return mv88e6xxx_phy_page_write(ds, phy, 6, 26,
-   (ret & 0xe0ff) | (temp << 8));
-}
-
-static int mv88e6352_get_temp_alarm(struct dsa_switch *ds, bool *alarm)
-{
-   int phy = mv88e6xxx_6320_family(ds) ? 3 : 0;
-   int ret;
-
-   *alarm = false;
-
-   ret = mv88e6xxx_phy_page_read(ds, phy, 6, 26);
-   if (ret < 0)
-   return ret;
-
-   *alarm = !!(ret & 0x40);
-
-   return 0;
-}
-#endif /* CONFIG_NET_DSA_HWMON */
-
 static int mv88e6352_setup(struct dsa_switch *ds)
 {
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
@@ -393,10 +329,10 @@ struct dsa_switch_driver mv88e6352_switch_driver = {
.set_eee= mv88e6xxx_set_eee,
.get_eee= mv88e6xxx_get_eee,
 #ifdef CONFIG_NET_DSA_HWMON
-   .get_temp   = mv88e6352_get_temp,
-   .get_temp_limit = mv88e6352_get_temp_limit,
-   .set_temp_limit = mv88e6352_set_temp_limit,
-   .get_temp_alarm = mv88e6352_get_temp_alarm,
+   .get_temp   = mv88e6xxx_get_temp,
+   .get_temp_limit = mv88e6xxx_get_temp_limit,
+   .set_temp_limit = mv88e6xxx_set_temp_limit,
+   .get_temp_alarm = mv88e6xxx_get_temp_alarm,
 #endif
.get_eeprom = mv88e6352_get_eeprom,
.set_eeprom = mv88e6352_set_eeprom,
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 5158375b7abd..61ce4cf120a6 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -517,7 +517,7 @@ static bool mv88e6xxx_6185_family(struct dsa_switch *ds)
return false;
 }
 
-bool mv88e6xxx_6320_family(struct dsa_switch *ds)
+static bool mv88e6xxx_6320_family(struct dsa_switch *ds)
 {
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 
@@ -808,54 +808,6 @@ void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
}
 }
 
-#ifdef CONFIG_NET_DSA_HWMON
-
-int  mv88e6xxx_get_temp(struct dsa_switch *ds, int *temp)
-{
-   struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
-   int ret;
-   int val;
-
-   *temp = 0;
-
-   mutex_lock(&ps->smi_mutex);
-
-   ret = _mv88e6xxx_phy_write(ds, 0x0, 0x16, 0x6);
-   if (ret < 0)
-   goto error;
-
-   /* Enable temperature sensor */
-   ret = _mv88e6xxx_phy_read(ds, 0x0, 0x1a);
-   if (ret < 0)
-   goto error;
-
-   ret = _mv88e6xxx_phy_write(ds, 0x0, 0x1a, ret | (1 << 5));
-   if (ret < 0)
-   goto error;
-
-   /* Wait for temperature to stabilize */
-   usleep_range(1, 12000);
-
-   val = _mv88e6xxx_phy_read(ds, 0x0, 0x1a);
-   if (val < 0) {
-   ret = val;
-   goto error;
-   }
-
-   /* Disable temperature sensor */
-   ret = _mv88e6xxx_phy_write(ds, 0x0, 0x1a, ret & ~(1 << 5));
-   if (ret < 0)
-   goto error;
-
-   *temp = ((val & 0x1f) - 5) * 5;
-
-error:
-   _mv88e6xxx_phy_write(ds, 0x0, 0x16, 0x0);
-   mutex_unlock(&ps->smi_mutex);
-   return ret;
-}
-#endif /* CONFIG_NET_DSA_HWMON */
-
 /* Must be called with

Re: [PATCH] dsa: mv88e6352/mv88e6xxx: Move temperature sensor code to mv88e6xxx.c

2015-07-25 Thread Andrew Lunn
On Sat, Jul 25, 2015 at 09:42:28AM -0700, Guenter Roeck wrote:
> Move the temperature sensing code for mv88e6352 and mv88e6320 families
> into mv88e6xxx.c to simplify adding support for additional chips.
> 
> With this change, mv88e6xxx_6320_family() no longer needs to be
> a global function and is made static.
> 
> Cc: Andrew Lunn 
> Signed-off-by: Guenter Roeck 

Acked-by: Andrew Lunn 

Thanks for doing this Guenter

   Andrew
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] dsa: mv88e6352/mv88e6xxx: Move temperature sensor code to mv88e6xxx.c

2015-07-25 Thread Vivien Didelot
On Jul 25, 2015, at 12:42 PM, Guenter Roeck li...@roeck-us.net wrote:

> Move the temperature sensing code for mv88e6352 and mv88e6320 families
> into mv88e6xxx.c to simplify adding support for additional chips.
> 
> With this change, mv88e6xxx_6320_family() no longer needs to be
> a global function and is made static.
> 
> Cc: Andrew Lunn 
> Signed-off-by: Guenter Roeck 

Tested-by: Vivien Didelot 

On a Marvell 88E6352.
Thanks,
-v
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ravb: minimize TX data copying

2015-07-25 Thread Sergei Shtylyov
Renesas Ethernet AVB controller requires that all data are aligned on 4-byte
boundary.  While it's  easily achievable for  the RX  data with  the help of
skb_reserve() (we even align on 128-byte boundary as recommended by the manual),
we  can't  do the same with the TX data, and it always comes  unaligned from
the networking core. Originally we solved it an easy way, copying all packet
to  a  preallocated  aligned buffer; however, it's enough to copy only up to
3 first bytes from each packet, doing the transfer using 2 TX descriptors
instead of just 1. Here's an implementation of the new  TX algorithm that
significantly reduces the driver's memory requirements.

Signed-off-by: Sergei Shtylyov 

---
The patch is against Dave Miller's 'net-next.git' repo.

 drivers/net/ethernet/renesas/ravb.h  |5 +
 drivers/net/ethernet/renesas/ravb_main.c |  104 +--
 2 files changed, 64 insertions(+), 45 deletions(-)

Index: net-next/drivers/net/ethernet/renesas/ravb.h
===
--- net-next.orig/drivers/net/ethernet/renesas/ravb.h
+++ net-next/drivers/net/ethernet/renesas/ravb.h
@@ -658,6 +658,8 @@ struct ravb_desc {
__le32 dptr;/* Descriptor pointer */
 };
 
+#define DPTR_ALIGN 4   /* Required data pointer alignment */
+
 enum DIE_DT {
/* Frame data */
DT_FMID = 0x40,
@@ -739,6 +741,7 @@ enum RAVB_QUEUE {
 #define RX_QUEUE_OFFSET4
 #define NUM_RX_QUEUE   2
 #define NUM_TX_QUEUE   2
+#define NUM_TX_DESC2   /* TX desciptors per packet */
 
 struct ravb_tstamp_skb {
struct list_head list;
@@ -777,9 +780,9 @@ struct ravb_private {
dma_addr_t tx_desc_dma[NUM_TX_QUEUE];
struct ravb_ex_rx_desc *rx_ring[NUM_RX_QUEUE];
struct ravb_tx_desc *tx_ring[NUM_TX_QUEUE];
+   void *tx_align[NUM_TX_QUEUE];
struct sk_buff **rx_skb[NUM_RX_QUEUE];
struct sk_buff **tx_skb[NUM_TX_QUEUE];
-   void **tx_buffers[NUM_TX_QUEUE];
u32 rx_over_errors;
u32 rx_fifo_errors;
struct net_device_stats stats[NUM_RX_QUEUE];
Index: net-next/drivers/net/ethernet/renesas/ravb_main.c
===
--- net-next.orig/drivers/net/ethernet/renesas/ravb_main.c
+++ net-next/drivers/net/ethernet/renesas/ravb_main.c
@@ -195,12 +195,8 @@ static void ravb_ring_free(struct net_de
priv->tx_skb[q] = NULL;
 
/* Free aligned TX buffers */
-   if (priv->tx_buffers[q]) {
-   for (i = 0; i < priv->num_tx_ring[q]; i++)
-   kfree(priv->tx_buffers[q][i]);
-   }
-   kfree(priv->tx_buffers[q]);
-   priv->tx_buffers[q] = NULL;
+   kfree(priv->tx_align[q]);
+   priv->tx_align[q] = NULL;
 
if (priv->rx_ring[q]) {
ring_size = sizeof(struct ravb_ex_rx_desc) *
@@ -212,7 +208,7 @@ static void ravb_ring_free(struct net_de
 
if (priv->tx_ring[q]) {
ring_size = sizeof(struct ravb_tx_desc) *
-   (priv->num_tx_ring[q] + 1);
+   (priv->num_tx_ring[q] * NUM_TX_DESC + 1);
dma_free_coherent(NULL, ring_size, priv->tx_ring[q],
  priv->tx_desc_dma[q]);
priv->tx_ring[q] = NULL;
@@ -227,7 +223,8 @@ static void ravb_ring_format(struct net_
struct ravb_tx_desc *tx_desc;
struct ravb_desc *desc;
int rx_ring_size = sizeof(*rx_desc) * priv->num_rx_ring[q];
-   int tx_ring_size = sizeof(*tx_desc) * priv->num_tx_ring[q];
+   int tx_ring_size = sizeof(*tx_desc) * priv->num_tx_ring[q] *
+  NUM_TX_DESC;
dma_addr_t dma_addr;
int i;
 
@@ -260,11 +257,12 @@ static void ravb_ring_format(struct net_
 
memset(priv->tx_ring[q], 0, tx_ring_size);
/* Build TX ring buffer */
-   for (i = 0; i < priv->num_tx_ring[q]; i++) {
-   tx_desc = &priv->tx_ring[q][i];
+   for (i = 0, tx_desc = priv->tx_ring[q]; i < priv->num_tx_ring[q];
+i++, tx_desc++) {
+   tx_desc->die_dt = DT_EEMPTY;
+   tx_desc++;
tx_desc->die_dt = DT_EEMPTY;
}
-   tx_desc = &priv->tx_ring[q][i];
tx_desc->dptr = cpu_to_le32((u32)priv->tx_desc_dma[q]);
tx_desc->die_dt = DT_LINKFIX; /* type */
 
@@ -285,7 +283,6 @@ static int ravb_ring_init(struct net_dev
struct ravb_private *priv = netdev_priv(ndev);
struct sk_buff *skb;
int ring_size;
-   void *buffer;
int i;
 
/* Allocate RX and TX skb rings */
@@ -305,19 +302,11 @@ static int ravb_ring_init(struct net_dev
}
 
/* Allocate rings for the aligned buffers */
-   priv->tx_buffers[q] = kcalloc(priv->num_tx_ring[q],
- sizeof(*priv->tx_buffers[q]), GFP_KERNEL);
-   if (!priv->tx_buffers[q])
+   priv->tx_align[q] = kmalloc(DPT

Re: [PATCH] dsa: mv88e6352/mv88e6xxx: Move temperature sensor code to mv88e6xxx.c

2015-07-25 Thread Guenter Roeck

On 07/25/2015 11:58 AM, Vivien Didelot wrote:

On Jul 25, 2015, at 12:42 PM, Guenter Roeck li...@roeck-us.net wrote:


Move the temperature sensing code for mv88e6352 and mv88e6320 families
into mv88e6xxx.c to simplify adding support for additional chips.

With this change, mv88e6xxx_6320_family() no longer needs to be
a global function and is made static.

Cc: Andrew Lunn 
Signed-off-by: Guenter Roeck 


Tested-by: Vivien Didelot 

On a Marvell 88E6352.


Thanks a lot for testing!

Guenter


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] dsa: mv88e6352/mv88e6xxx: Move temperature sensor code to mv88e6xxx.c

2015-07-25 Thread Guenter Roeck

On 07/25/2015 11:46 AM, Andrew Lunn wrote:

On Sat, Jul 25, 2015 at 09:42:28AM -0700, Guenter Roeck wrote:

Move the temperature sensing code for mv88e6352 and mv88e6320 families
into mv88e6xxx.c to simplify adding support for additional chips.

With this change, mv88e6xxx_6320_family() no longer needs to be
a global function and is made static.

Cc: Andrew Lunn 
Signed-off-by: Guenter Roeck 


Acked-by: Andrew Lunn 

Thanks for doing this Guenter


My pleasure. Thanks a lot for the review!

Guenter


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ravb: minimize TX data copying

2015-07-25 Thread Jiri Pirko
Sat, Jul 25, 2015 at 09:20:30PM CEST, sergei.shtyl...@cogentembedded.com wrote:



>The patch is against Dave Miller's 'net-next.git' repo.

You can just put "net-next" into patch brackets like:
[patch net-next] whatever
That would do the trick :)
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] ravb: minimize TX data copying

2015-07-25 Thread Sergei Shtylyov
Renesas Ethernet AVB controller requires that all data are aligned on 4-byte
boundary.  While it's  easily achievable for  the RX  data with  the help of
skb_reserve() (we even align on 128-byte boundary as recommended by the manual),
we  can't  do the same with the TX data, and it always comes  unaligned from
the networking core. Originally we solved it an easy way, copying all packet
to  a  preallocated  aligned buffer; however, it's enough to copy only up to
3 first bytes from each packet, doing the transfer using 2 TX descriptors
instead of just 1. Here's an implementation of the new  TX algorithm that
significantly reduces the driver's memory requirements.

Signed-off-by: Sergei Shtylyov 

---
The patch is against Dave Miller's 'net-next.git' repo.

Changes in version 2:
- fixed terminology in the comment to #define DPTR_ALIGN;
- fixed a typo in the coment to #define NUM_TX_DESC.

 drivers/net/ethernet/renesas/ravb.h  |5 +
 drivers/net/ethernet/renesas/ravb_main.c |  104 +--
 2 files changed, 64 insertions(+), 45 deletions(-)

Index: net-next/drivers/net/ethernet/renesas/ravb.h
===
--- net-next.orig/drivers/net/ethernet/renesas/ravb.h
+++ net-next/drivers/net/ethernet/renesas/ravb.h
@@ -658,6 +658,8 @@ struct ravb_desc {
__le32 dptr;/* Descriptor pointer */
 };
 
+#define DPTR_ALIGN 4   /* Required descriptor pointer alignment */
+
 enum DIE_DT {
/* Frame data */
DT_FMID = 0x40,
@@ -739,6 +741,7 @@ enum RAVB_QUEUE {
 #define RX_QUEUE_OFFSET4
 #define NUM_RX_QUEUE   2
 #define NUM_TX_QUEUE   2
+#define NUM_TX_DESC2   /* TX descriptors per packet */
 
 struct ravb_tstamp_skb {
struct list_head list;
@@ -777,9 +780,9 @@ struct ravb_private {
dma_addr_t tx_desc_dma[NUM_TX_QUEUE];
struct ravb_ex_rx_desc *rx_ring[NUM_RX_QUEUE];
struct ravb_tx_desc *tx_ring[NUM_TX_QUEUE];
+   void *tx_align[NUM_TX_QUEUE];
struct sk_buff **rx_skb[NUM_RX_QUEUE];
struct sk_buff **tx_skb[NUM_TX_QUEUE];
-   void **tx_buffers[NUM_TX_QUEUE];
u32 rx_over_errors;
u32 rx_fifo_errors;
struct net_device_stats stats[NUM_RX_QUEUE];
Index: net-next/drivers/net/ethernet/renesas/ravb_main.c
===
--- net-next.orig/drivers/net/ethernet/renesas/ravb_main.c
+++ net-next/drivers/net/ethernet/renesas/ravb_main.c
@@ -195,12 +195,8 @@ static void ravb_ring_free(struct net_de
priv->tx_skb[q] = NULL;
 
/* Free aligned TX buffers */
-   if (priv->tx_buffers[q]) {
-   for (i = 0; i < priv->num_tx_ring[q]; i++)
-   kfree(priv->tx_buffers[q][i]);
-   }
-   kfree(priv->tx_buffers[q]);
-   priv->tx_buffers[q] = NULL;
+   kfree(priv->tx_align[q]);
+   priv->tx_align[q] = NULL;
 
if (priv->rx_ring[q]) {
ring_size = sizeof(struct ravb_ex_rx_desc) *
@@ -212,7 +208,7 @@ static void ravb_ring_free(struct net_de
 
if (priv->tx_ring[q]) {
ring_size = sizeof(struct ravb_tx_desc) *
-   (priv->num_tx_ring[q] + 1);
+   (priv->num_tx_ring[q] * NUM_TX_DESC + 1);
dma_free_coherent(NULL, ring_size, priv->tx_ring[q],
  priv->tx_desc_dma[q]);
priv->tx_ring[q] = NULL;
@@ -227,7 +223,8 @@ static void ravb_ring_format(struct net_
struct ravb_tx_desc *tx_desc;
struct ravb_desc *desc;
int rx_ring_size = sizeof(*rx_desc) * priv->num_rx_ring[q];
-   int tx_ring_size = sizeof(*tx_desc) * priv->num_tx_ring[q];
+   int tx_ring_size = sizeof(*tx_desc) * priv->num_tx_ring[q] *
+  NUM_TX_DESC;
dma_addr_t dma_addr;
int i;
 
@@ -260,11 +257,12 @@ static void ravb_ring_format(struct net_
 
memset(priv->tx_ring[q], 0, tx_ring_size);
/* Build TX ring buffer */
-   for (i = 0; i < priv->num_tx_ring[q]; i++) {
-   tx_desc = &priv->tx_ring[q][i];
+   for (i = 0, tx_desc = priv->tx_ring[q]; i < priv->num_tx_ring[q];
+i++, tx_desc++) {
+   tx_desc->die_dt = DT_EEMPTY;
+   tx_desc++;
tx_desc->die_dt = DT_EEMPTY;
}
-   tx_desc = &priv->tx_ring[q][i];
tx_desc->dptr = cpu_to_le32((u32)priv->tx_desc_dma[q]);
tx_desc->die_dt = DT_LINKFIX; /* type */
 
@@ -285,7 +283,6 @@ static int ravb_ring_init(struct net_dev
struct ravb_private *priv = netdev_priv(ndev);
struct sk_buff *skb;
int ring_size;
-   void *buffer;
int i;
 
/* Allocate RX and TX skb rings */
@@ -305,19 +302,11 @@ static int ravb_ring_init(struct net_dev
}
 
/* Allocate rings for the aligned buffers */
-   priv->tx_buffers[q] = kcalloc(priv->num_tx_ring[q],
-

[PATCHv6 RFT] net: fec: Ensure clocks are enabled while using mdio bus

2015-07-25 Thread Andrew Lunn
When a switch is attached to the mdio bus, the mdio bus can be used
while the interface is not open. If the IPG clock is not enabled, MDIO
reads/writes will simply time out.

Add support for runtime PM to control this clock. Enable/disable this
clock using runtime PM, with open()/close() and mdio read()/write()
function triggering runtime PM operations. Since PM is optional, the
IPG clock is enabled at probe and is no longer modified by
fec_enet_clk_enable(), thus if PM is not enabled in the kernel, it is
guaranteed the clock is running when MDIO operations are performed.

Signed-off-by: Andrew Lunn 
Signed-off-by: Lucas Stach 
Cc: tyler.ba...@linaro.org
Cc: fabio.este...@freescale.com
Cc: shawn@linaro.org
---

v5 was accepted and then reverted, because it broke imx6.  Lucas Stach
debugged what was going wrong and provided a patch. Thanks Lucas. This
has been squashed into v6.

It would be good if this version had more testing on various platforms
before it is accepted. If you reported a problem last time, please do
test and send a Tested-by:

I'm out the office for a week starting tomorrow.

Thanks
Andrew

v6: Move the runtime PM setup before the mdio probe.

Also move autosuspend init calls before runtime_pm_enable() so
that the RPM callbacks aren't invoked several times during the
probe function.
---
 drivers/net/ethernet/freescale/fec_main.c | 89 ++-
 1 file changed, 76 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c 
b/drivers/net/ethernet/freescale/fec_main.c
index 1f89c59b4353..349365d85b92 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -77,6 +78,7 @@ static void fec_enet_itr_coal_init(struct net_device *ndev);
 #define FEC_ENET_RAEM_V0x8
 #define FEC_ENET_RAFL_V0x8
 #define FEC_ENET_OPD_V 0xFFF0
+#define FEC_MDIO_PM_TIMEOUT  100 /* ms */
 
 static struct platform_device_id fec_devtype[] = {
{
@@ -1767,7 +1769,13 @@ static void fec_enet_adjust_link(struct net_device *ndev)
 static int fec_enet_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
 {
struct fec_enet_private *fep = bus->priv;
+   struct device *dev = &fep->pdev->dev;
unsigned long time_left;
+   int ret = 0;
+
+   ret = pm_runtime_get_sync(dev);
+   if (IS_ERR_VALUE(ret))
+   return ret;
 
fep->mii_timeout = 0;
init_completion(&fep->mdio_done);
@@ -1783,18 +1791,30 @@ static int fec_enet_mdio_read(struct mii_bus *bus, int 
mii_id, int regnum)
if (time_left == 0) {
fep->mii_timeout = 1;
netdev_err(fep->netdev, "MDIO read timeout\n");
-   return -ETIMEDOUT;
+   ret = -ETIMEDOUT;
+   goto out;
}
 
-   /* return value */
-   return FEC_MMFR_DATA(readl(fep->hwp + FEC_MII_DATA));
+   ret = FEC_MMFR_DATA(readl(fep->hwp + FEC_MII_DATA));
+
+out:
+   pm_runtime_mark_last_busy(dev);
+   pm_runtime_put_autosuspend(dev);
+
+   return ret;
 }
 
 static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
   u16 value)
 {
struct fec_enet_private *fep = bus->priv;
+   struct device *dev = &fep->pdev->dev;
unsigned long time_left;
+   int ret = 0;
+
+   ret = pm_runtime_get_sync(dev);
+   if (IS_ERR_VALUE(ret))
+   return ret;
 
fep->mii_timeout = 0;
init_completion(&fep->mdio_done);
@@ -1811,10 +1831,13 @@ static int fec_enet_mdio_write(struct mii_bus *bus, int 
mii_id, int regnum,
if (time_left == 0) {
fep->mii_timeout = 1;
netdev_err(fep->netdev, "MDIO write timeout\n");
-   return -ETIMEDOUT;
+   ret  = -ETIMEDOUT;
}
 
-   return 0;
+   pm_runtime_mark_last_busy(dev);
+   pm_runtime_put_autosuspend(dev);
+
+   return ret;
 }
 
 static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
@@ -1826,9 +1849,6 @@ static int fec_enet_clk_enable(struct net_device *ndev, 
bool enable)
ret = clk_prepare_enable(fep->clk_ahb);
if (ret)
return ret;
-   ret = clk_prepare_enable(fep->clk_ipg);
-   if (ret)
-   goto failed_clk_ipg;
if (fep->clk_enet_out) {
ret = clk_prepare_enable(fep->clk_enet_out);
if (ret)
@@ -1852,7 +1872,6 @@ static int fec_enet_clk_enable(struct net_device *ndev, 
bool enable)
}
} else {
clk_disable_unprepare(fep->clk_ahb);
-   clk_disable_unprepare(fep->clk_ipg);
if (fep->clk_enet_out)
clk_disable_unprepare(fep->clk_enet_out);
if (fep->clk_ptp) {
@

Re: [PATCH] ravb: minimize TX data copying

2015-07-25 Thread Sergei Shtylyov

Hello.

On 07/25/2015 11:40 PM, Jiri Pirko wrote:






The patch is against Dave Miller's 'net-next.git' repo.


   Dave, don't apply this yet, I'll post v2 with couple of comments fixed up.


You can just put "net-next" into patch brackets like:
[patch net-next] whatever
That would do the trick :)


   Oh, I know. :-)
   I just prefer to do this kind of thing uniformly regardless of the target 
repo.


MBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv6 RFT] net: fec: Ensure clocks are enabled while using mdio bus

2015-07-25 Thread Fabio Estevam
Hi Andrew,

On Sat, Jul 25, 2015 at 5:38 PM, Andrew Lunn  wrote:
> When a switch is attached to the mdio bus, the mdio bus can be used
> while the interface is not open. If the IPG clock is not enabled, MDIO
> reads/writes will simply time out.
>
> Add support for runtime PM to control this clock. Enable/disable this
> clock using runtime PM, with open()/close() and mdio read()/write()
> function triggering runtime PM operations. Since PM is optional, the
> IPG clock is enabled at probe and is no longer modified by
> fec_enet_clk_enable(), thus if PM is not enabled in the kernel, it is
> guaranteed the clock is running when MDIO operations are performed.
>
> Signed-off-by: Andrew Lunn 
> Signed-off-by: Lucas Stach 
> Cc: tyler.ba...@linaro.org
> Cc: fabio.este...@freescale.com
> Cc: shawn@linaro.org
> ---
>
> v5 was accepted and then reverted, because it broke imx6.  Lucas Stach
> debugged what was going wrong and provided a patch. Thanks Lucas. This
> has been squashed into v6.
>
> It would be good if this version had more testing on various platforms
> before it is accepted. If you reported a problem last time, please do
> test and send a Tested-by:

With this version I can boot via NFS on a mx6 board:

Tested-by: Fabio Estevam 

Thanks
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next 3/3] openvswitch: 802.1AD: Flow handling, actions, and vlan parsing

2015-07-25 Thread Thomas F Herbert

On 6/30/15 12:16 AM, Pravin Shelar wrote:

On Tue, Jun 23, 2015 at 11:26 AM, Thomas F Herbert
Pravin, I apologize because I realize now that I am finishing V12 of 
this patch that I never responded to your comments in this email.

 wrote:

Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert 
---
  net/openvswitch/flow.c |  84 +++---
  net/openvswitch/flow.h |   5 ++
  net/openvswitch/flow_netlink.c | 195 ++---
  3 files changed, 242 insertions(+), 42 deletions(-)

diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index 2dacc7b..e268865 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -298,21 +298,80 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
  static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
  {
 struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
 __be16 tci;
 };
-   struct qtag_prefix *qp;
+   struct qtag_prefix *qp = (struct qtag_prefix *)skb->data;

-   if (unlikely(skb->len < sizeof(struct qtag_prefix) + sizeof(__be16)))
+   struct qinqtag_prefix {
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
+   __be16 tci;
+   __be16 inner_tpid; /* ETH_P_8021Q */
+   __be16 ctci;
+   };
+
+   if (likely(skb_vlan_tag_present(skb))) {
+   key->eth.tci = htons(skb->vlan_tci);
+
+   /* Case where upstream
+* processing has already stripped the outer vlan tag.
+*/
+   if (unlikely(skb->vlan_proto == htons(ETH_P_8021AD))) {
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16))) {
+   key->eth.tci = 0;
+   return 0;
+   }
+
+   if (unlikely(!pskb_may_pull(skb,
+   sizeof(struct qtag_prefix) +
+   sizeof(__be16 {
+   return -ENOMEM;
+   }
+
+   if (likely(qp->eth_type == htons(ETH_P_8021Q))) {
+   key->eth.cvlan.ctci =
+   qp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.c_tpid = skb->vlan_proto;


We should directly copy qp->inner_tpid here. As you have done it for
non offloaded case below.
Thanks! It is copied but it is set to the wrong tpid. The c_tpid field 
in the key should be set to the ethertype in the packet itself which is 
the inner tpid, not the offloaded skb-vlan_proto which is the outer 
tpid. Fixed in V12.



+   __skb_pull(skb, sizeof(struct qtag_prefix));
+   }
+   }
 return 0;
+   }

-   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
-sizeof(__be16
-   return -ENOMEM;

-   qp = (struct qtag_prefix *) skb->data;
-   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
-   __skb_pull(skb, sizeof(struct qtag_prefix));
+   if (qp->eth_type == htons(ETH_P_8021AD)) {
+   struct qinqtag_prefix *qinqp =
+   (struct qinqtag_prefix *)skb->data;
+
+   if (unlikely(skb->len < sizeof(struct qinqtag_prefix) +
+   sizeof(__be16)))
+   return 0;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qinqtag_prefix) +
+   sizeof(__be16 {
+   return -ENOMEM;
+   }
+   key->eth.tci = qinqp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.ctci = qinqp->ctci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.c_tpid = qinqp->inner_tpid;
+
+   __skb_pull(skb, sizeof(struct qinqtag_prefix));
+
+   return 0;
+   }
+   if (qp->eth_type == htons(ETH_P_8021Q)) {
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16)))
+   return -ENOMEM;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return 0;
+   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
+
+   __skb_pull(skb, sizeof(struct qtag_prefix));
+   }

 return 0;
  }
@@ -474,9 

Re: [PATCHv6 RFT] net: fec: Ensure clocks are enabled while using mdio bus

2015-07-25 Thread Tyler Baker
Hi Andrew,

On 25 July 2015 at 13:38, Andrew Lunn  wrote:
> When a switch is attached to the mdio bus, the mdio bus can be used
> while the interface is not open. If the IPG clock is not enabled, MDIO
> reads/writes will simply time out.
>
> Add support for runtime PM to control this clock. Enable/disable this
> clock using runtime PM, with open()/close() and mdio read()/write()
> function triggering runtime PM operations. Since PM is optional, the
> IPG clock is enabled at probe and is no longer modified by
> fec_enet_clk_enable(), thus if PM is not enabled in the kernel, it is
> guaranteed the clock is running when MDIO operations are performed.
>
> Signed-off-by: Andrew Lunn 
> Signed-off-by: Lucas Stach 
> Cc: tyler.ba...@linaro.org
> Cc: fabio.este...@freescale.com
> Cc: shawn@linaro.org
> ---
>
> v5 was accepted and then reverted, because it broke imx6.  Lucas Stach
> debugged what was going wrong and provided a patch. Thanks Lucas. This
> has been squashed into v6.
>
> It would be good if this version had more testing on various platforms
> before it is accepted. If you reported a problem last time, please do
> test and send a Tested-by:

I've tested this single patch (v6) on top of next-20150724 using the
kernelci.org bot to build and boot test[1][2] on a broad range of
platforms. With these results, I can confirm that the imx6 platforms
tested are booting fine, and that no new boot/build regressions have
been introduced when comparing these results to the next-20150724
baseline[3][4].

Tested-by: Tyler Baker 

Cheers,

Tyler

[1] http://kernelci.org/boot/all/job/tbaker/kernel/v4.2-rc3-4216-g8c8efbc4423a/
[2] http://kernelci.org/build/tbaker/kernel/v4.2-rc3-4216-g8c8efbc4423a/
[3] http://kernelci.org/boot/all/job/next/kernel/next-20150724/
[4] http://kernelci.org/build/next/kernel/next-20150724/
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch net-next 4/4] mlxsw: Introduce Mellanox SwitchX-2 ASIC support

2015-07-25 Thread Scott Feldman
On Thu, Jul 23, 2015 at 8:43 AM, Jiri Pirko  wrote:
> From: Jiri Pirko 
>
> Benefit from the previously introduced Mellanox Switch infrastructure and
> add driver for SwitchX-2 ASIC. Note that this driver is very simple now.
> It implements bare minimum for getting device to work on slow-path.
> Fast-path offload functionality is going to be added soon.
>
> Signed-off-by: Jiri Pirko 
> Signed-off-by: Ido Schimmel 
> Signed-off-by: Elad Raz 

[cut]

> +static netdev_tx_t mlxsw_sx_port_xmit(struct sk_buff *skb,
> + struct net_device *dev)
> +{
> +   struct mlxsw_sx_port *mlxsw_sx_port = netdev_priv(dev);
> +   struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx;
> +   struct mlxsw_sx_port_pcpu_stats *pcpu_stats;
> +   const struct mlxsw_tx_info tx_info = {
> +   .local_port = mlxsw_sx_port->local_port,
> +   .is_emad = false,
> +   };
> +   int err;
> +
> +   if (unlikely(skb_headroom(skb) < MLXSW_TXHDR_LEN)) {

Does this happen at all since dev->hard_header_len was set in probe to
add MLXSW_TXHDR_LEN?

> +   struct sk_buff *skb_new;
> +
> +   skb_new = skb_realloc_headroom(skb, MLXSW_TXHDR_LEN);
> +   dev_kfree_skb_any(skb);
> +   if (!skb_new) {
> +   this_cpu_inc(mlxsw_sx_port->pcpu_stats->tx_dropped);
> +   return NETDEV_TX_OK;
> +   }
> +   skb = skb_new;
> +   }
> +   mlxsw_sx_txhdr_construct(skb, &tx_info);
> +   err = mlxsw_core_skb_transmit(mlxsw_sx, skb, &tx_info);
> +   if (err == -EAGAIN)
> +   return NETDEV_TX_BUSY;

I think there is a problem here when returning NETDEV_TX_BUSY when
original skb might have been freed above in the headroom check. (ref
Documentation/networking/driver.txt).

[cut]

> +static int mlxsw_sx_port_dev_addr_get(struct mlxsw_sx_port *mlxsw_sx_port)
> +{
> +   struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx;
> +   struct net_device *dev = mlxsw_sx_port->dev;
> +   char ppad_pl[MLXSW_REG_PPAD_LEN];
> +   int err;
> +
> +   mlxsw_reg_ppad_pack(ppad_pl, false, 0);
> +   err = mlxsw_reg_query(mlxsw_sx->core, MLXSW_REG(ppad), ppad_pl);
> +   if (err)
> +   return err;
> +   mlxsw_reg_ppad_mac_memcpy_from(ppad_pl, dev->dev_addr);
> +   /* The last byte in base mac address is always 0 */
> +   dev->dev_addr[ETH_ALEN - 1] += mlxsw_sx_port->local_port;

If MLXSW_PORT_MAX_PORTS > 256, you'll wrap this.  Is dev_addr[ETH_ALEN
- 2] available to carry into?

> +   return 0;
> +}
> +

[cut]

> +static int mlxsw_sx_port_create(struct mlxsw_sx *mlxsw_sx, u8 local_port)
> +{
> +   struct mlxsw_sx_port *mlxsw_sx_port;
> +   struct net_device *dev;
> +   bool usable;
> +   int err;
> +
> +   dev = alloc_etherdev(sizeof(struct mlxsw_sx_port));
> +   if (!dev)
> +   return -ENOMEM;
> +   mlxsw_sx_port = netdev_priv(dev);
> +   mlxsw_sx_port->dev = dev;
> +   mlxsw_sx_port->mlxsw_sx = mlxsw_sx;
> +   mlxsw_sx_port->local_port = local_port;
> +
> +   mlxsw_sx_port->pcpu_stats =
> +   netdev_alloc_pcpu_stats(struct mlxsw_sx_port_pcpu_stats);
> +   if (!mlxsw_sx_port->pcpu_stats) {
> +   err = -ENOMEM;
> +   goto err_alloc_stats;
> +   }
> +
> +   dev->netdev_ops = &mlxsw_sx_port_netdev_ops;
> +   dev->ethtool_ops = &mlxsw_sx_port_ethtool_ops;
> +   dev->switchdev_ops = &mlxsw_sx_port_switchdev_ops;
> +
> +   err = mlxsw_sx_port_dev_addr_get(mlxsw_sx_port);
> +   if (err) {
> +   dev_err(mlxsw_sx->bus_info->dev, "Port %d: Unable to get port 
> mac address\n",
> +   mlxsw_sx_port->local_port);
> +   goto err_dev_addr_get;
> +   }
> +
> +   netif_carrier_off(dev);
> +
> +   dev->features |= NETIF_F_NETNS_LOCAL | NETIF_F_LLTX |

Not supposed to use LLTX in new drivers, according to
include/linux/netdev_features.h.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch net-next 2/4] mlxsw: Add PCI bus implementation

2015-07-25 Thread Scott Feldman
On Thu, Jul 23, 2015 at 8:43 AM, Jiri Pirko  wrote:
> From: Jiri Pirko 
>
> Add PCI bus implementation for Mellanox Technologies Switch ASICs. This
> includes firmware initialization, async queues manipulation and command
> interface implementation.
>
> Signed-off-by: Jiri Pirko 
> Signed-off-by: Ido Schimmel 
> Signed-off-by: Elad Raz 
> ---

[cut]

> +static int mlxsw_pci_fw_area_init(struct mlxsw_pci *mlxsw_pci, char *mbox,
> + u16 num_pages)
> +{
> +   struct mlxsw_pci_mem_item *mem_item;
> +   int i;
> +   int err;

Need to init err to zero here

> +
> +   mlxsw_pci->fw_area.items = kcalloc(num_pages, sizeof(*mem_item),
> +  GFP_KERNEL);
> +   if (!mlxsw_pci->fw_area.items)
> +   return -ENOMEM;
> +   mlxsw_pci->fw_area.num_pages = num_pages;
> +
> +   mlxsw_cmd_mbox_zero(mbox);
> +   for (i = 0; i < num_pages; i++) {
> +   mem_item = &mlxsw_pci->fw_area.items[i];
> +
> +   mem_item->size = MLXSW_PCI_PAGE_SIZE;
> +   mem_item->buf = pci_alloc_consistent(mlxsw_pci->pdev,
> +mem_item->size,
> +&mem_item->mapaddr);
> +   if (!mem_item->buf)
> +   goto err_alloc;
> +   mlxsw_cmd_mbox_map_fa_pa_set(mbox, i, mem_item->mapaddr);
> +   mlxsw_cmd_mbox_map_fa_log2size_set(mbox, i, 0); /* 1 page */
> +   }
> +
> +   err = mlxsw_cmd_map_fa(mlxsw_pci->core, mbox, num_pages);
> +   if (err)
> +   goto err_cmd_map_fa;
> +
> +   return 0;
> +
> +err_cmd_map_fa:
> +err_alloc:
> +   for (i--; i >= 0; i--) {
> +   mem_item = &mlxsw_pci->fw_area.items[i];
> +
> +   pci_free_consistent(mlxsw_pci->pdev, mem_item->size,
> +   mem_item->buf, mem_item->mapaddr);
> +   }
> +   kfree(mlxsw_pci->fw_area.items);
> +   return err;
> +}
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html