[PATCH] staging: android: formatting change in ashmem.c

2019-02-05 Thread K Hodges
Resolved "Line over 80 characters" warning from checkpatch

Signed-off-by: K Hodges 
---
 drivers/staging/android/ashmem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index 90a8a9f1ac7d..92f42cea5ae4 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -126,7 +126,8 @@ static inline bool page_range_in_range(struct ashmem_range 
*range,
page_range_subsumes_range(range, start, end);
 }
 
-static inline bool range_before_page(struct ashmem_range *range, size_t page)
+static inline bool range_before_page(struct ashmem_range *range,
+size_t page)
 {
return range->pgend < page;
 }
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next v3 10/12] staging: fsl-dpaa2: ethsw: Implement ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
ethsw implements SWITCHDEV_ATTR_ID_PORT_PARENT_ID and we want to get rid
of switchdev_ops eventually, ease that migration by implementing a
ndo_get_port_parent_id() function which returns what
switchdev_port_attr_get() would do.

Signed-off-by: Florian Fainelli 
---
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index daabaceeea52..e559f4c25cf7 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -505,6 +505,17 @@ static netdev_tx_t port_dropframe(struct sk_buff *skb,
return NETDEV_TX_OK;
 }
 
+static int swdev_get_port_parent_id(struct net_device *dev,
+   struct netdev_phys_item_id *ppid)
+{
+   struct ethsw_port_priv *port_priv = netdev_priv(dev);
+
+   ppid->id_len = 1;
+   ppid->id[0] = port_priv->ethsw_data->dev_id;
+
+   return 0;
+}
+
 static const struct net_device_ops ethsw_port_ops = {
.ndo_open   = port_open,
.ndo_stop   = port_stop,
@@ -515,6 +526,7 @@ static const struct net_device_ops ethsw_port_ops = {
.ndo_get_offload_stats  = port_get_offload_stats,
 
.ndo_start_xmit = port_dropframe,
+   .ndo_get_port_parent_id = swdev_get_port_parent_id,
 };
 
 static void ethsw_links_state_update(struct ethsw_core *ethsw)
@@ -634,10 +646,6 @@ static int swdev_port_attr_get(struct net_device *netdev,
struct ethsw_port_priv *port_priv = netdev_priv(netdev);
 
switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = 1;
-   attr->u.ppid.id[0] = port_priv->ethsw_data->dev_id;
-   break;
case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
attr->u.brport_flags =
(port_priv->ethsw_data->learning ? BR_LEARNING : 0) |
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next v3 12/12] net: Get rid of SWITCHDEV_ATTR_ID_PORT_PARENT_ID

2019-02-05 Thread Florian Fainelli
Now that we have a dedicated NDO for getting a port's parent ID, get rid
of SWITCHDEV_ATTR_ID_PORT_PARENT_ID and convert all callers to use the
NDO exclusively. This is a preliminary change to getting rid of
switchdev_ops eventually.

Signed-off-by: Florian Fainelli 
---
 include/net/switchdev.h   | 11 ---
 net/bridge/br_switchdev.c | 16 
 net/core/net-sysfs.c  | 19 ---
 net/core/rtnetlink.c  | 18 --
 net/ipv4/ipmr.c   | 16 
 net/switchdev/switchdev.c | 20 
 6 files changed, 16 insertions(+), 84 deletions(-)

diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index 63843ae5dc81..5e87b54c5dc5 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -43,7 +43,6 @@ static inline bool switchdev_trans_ph_commit(struct 
switchdev_trans *trans)
 
 enum switchdev_attr_id {
SWITCHDEV_ATTR_ID_UNDEFINED,
-   SWITCHDEV_ATTR_ID_PORT_PARENT_ID,
SWITCHDEV_ATTR_ID_PORT_STP_STATE,
SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS,
SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT,
@@ -61,7 +60,6 @@ struct switchdev_attr {
void *complete_priv;
void (*complete)(struct net_device *dev, int err, void *priv);
union {
-   struct netdev_phys_item_id ppid;/* PORT_PARENT_ID */
u8 stp_state;   /* PORT_STP_STATE */
unsigned long brport_flags; /* PORT_BRIDGE_FLAGS */
unsigned long brport_flags_support; /* 
PORT_BRIDGE_FLAGS_SUPPORT */
@@ -208,9 +206,6 @@ void switchdev_port_fwd_mark_set(struct net_device *dev,
 struct net_device *group_dev,
 bool joining);
 
-bool switchdev_port_same_parent_id(struct net_device *a,
-  struct net_device *b);
-
 int switchdev_handle_port_obj_add(struct net_device *dev,
struct switchdev_notifier_port_obj_info *port_obj_info,
bool (*check_cb)(const struct net_device *dev),
@@ -295,12 +290,6 @@ call_switchdev_blocking_notifiers(unsigned long val,
return NOTIFY_DONE;
 }
 
-static inline bool switchdev_port_same_parent_id(struct net_device *a,
-struct net_device *b)
-{
-   return false;
-}
-
 static inline int
 switchdev_handle_port_obj_add(struct net_device *dev,
struct switchdev_notifier_port_obj_info *port_obj_info,
diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
index 06b0ae44585f..c86d0f4a6aa8 100644
--- a/net/bridge/br_switchdev.c
+++ b/net/bridge/br_switchdev.c
@@ -14,8 +14,7 @@ static int br_switchdev_mark_get(struct net_bridge *br, 
struct net_device *dev)
 
/* dev is yet to be added to the port list. */
list_for_each_entry(p, &br->port_list, list) {
-   if (netdev_port_same_parent_id(dev, p->dev) ||
-   switchdev_port_same_parent_id(dev, p->dev))
+   if (netdev_port_same_parent_id(dev, p->dev))
return p->offload_fwd_mark;
}
 
@@ -24,19 +23,12 @@ static int br_switchdev_mark_get(struct net_bridge *br, 
struct net_device *dev)
 
 int nbp_switchdev_mark_set(struct net_bridge_port *p)
 {
-   const struct net_device_ops *ops = p->dev->netdev_ops;
-   struct switchdev_attr attr = {
-   .orig_dev = p->dev,
-   .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID,
-   };
-   int err;
+   struct netdev_phys_item_id ppid = { };
+   int err = -EOPNOTSUPP;
 
ASSERT_RTNL();
 
-   if (ops->ndo_get_port_parent_id)
-   err = dev_get_port_parent_id(p->dev, &attr.u.ppid, true);
-   else
-   err = switchdev_port_attr_get(p->dev, &attr);
+   err = dev_get_port_parent_id(p->dev, &ppid, true);
if (err) {
if (err == -EOPNOTSUPP)
return 0;
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 4eace9f1dcf9..7c5061123ead 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -12,7 +12,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -495,27 +494,17 @@ static ssize_t phys_switch_id_show(struct device *dev,
   struct device_attribute *attr, char *buf)
 {
struct net_device *netdev = to_net_dev(dev);
-   const struct net_device_ops *ops = netdev->netdev_ops;
ssize_t ret = -EINVAL;
 
if (!rtnl_trylock())
return restart_syscall();
 
if (dev_isalive(netdev)) {
-   struct switchdev_attr attr = {
-   .orig_dev = netdev,
-   .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID,
-   .flags = SWITCHDEV_F_NO_RECURSE,
-   };
-
-   if (ops->ndo_get_port_parent_id)
-   ret = d

[PATCH net-next v3 03/12] liquidio: Implement ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
Liquidio only supports SWITCHDEV_ATTR_ID_PORT_PARENT_ID, which makes it
a great candidate to be converted to use the ndo_get_port_parent_id()
NDO instead of implementing switchdev_port_attr_get().

Signed-off-by: Florian Fainelli 
---
 .../net/ethernet/cavium/liquidio/lio_main.c   | 22 
 .../net/ethernet/cavium/liquidio/lio_vf_rep.c | 25 ++-
 2 files changed, 12 insertions(+), 35 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 3d24133e5e49..e97e6754ee09 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -21,7 +21,6 @@
 #include 
 #include 
 #include 
-#include 
 #include "liquidio_common.h"
 #include "octeon_droq.h"
 #include "octeon_iq.h"
@@ -3184,7 +3183,8 @@ static const struct devlink_ops liquidio_devlink_ops = {
 };
 
 static int
-lio_pf_switchdev_attr_get(struct net_device *dev, struct switchdev_attr *attr)
+liquidio_get_port_parent_id(struct net_device *dev,
+   struct netdev_phys_item_id *ppid)
 {
struct lio *lio = GET_LIO(dev);
struct octeon_device *oct = lio->oct_dev;
@@ -3192,24 +3192,12 @@ lio_pf_switchdev_attr_get(struct net_device *dev, 
struct switchdev_attr *attr)
if (oct->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV)
return -EOPNOTSUPP;
 
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = ETH_ALEN;
-   ether_addr_copy(attr->u.ppid.id,
-   (void *)&lio->linfo.hw_addr + 2);
-   break;
-
-   default:
-   return -EOPNOTSUPP;
-   }
+   ppid->id_len = ETH_ALEN;
+   ether_addr_copy(ppid->id, (void *)&lio->linfo.hw_addr + 2);
 
return 0;
 }
 
-static const struct switchdev_ops lio_pf_switchdev_ops = {
-   .switchdev_port_attr_get = lio_pf_switchdev_attr_get,
-};
-
 static int liquidio_get_vf_stats(struct net_device *netdev, int vfidx,
 struct ifla_vf_stats *vf_stats)
 {
@@ -3259,6 +3247,7 @@ static const struct net_device_ops lionetdevops = {
.ndo_set_vf_trust   = liquidio_set_vf_trust,
.ndo_set_vf_link_state  = liquidio_set_vf_link_state,
.ndo_get_vf_stats   = liquidio_get_vf_stats,
+   .ndo_get_port_parent_id = liquidio_get_port_parent_id,
 };
 
 /** \brief Entry point for the liquidio module
@@ -3534,7 +3523,6 @@ static int setup_nic_devices(struct octeon_device 
*octeon_dev)
 * netdev tasks.
 */
netdev->netdev_ops = &lionetdevops;
-   SWITCHDEV_SET_OPS(netdev, &lio_pf_switchdev_ops);
 
retval = netif_set_real_num_rx_queues(netdev, num_oqueues);
if (retval) {
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c 
b/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c
index de61060721c4..f3f2e71431ac 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c
@@ -25,7 +25,6 @@
 #include "octeon_nic.h"
 #include "octeon_main.h"
 #include "octeon_network.h"
-#include 
 #include "lio_vf_rep.h"
 
 static int lio_vf_rep_open(struct net_device *ndev);
@@ -38,6 +37,8 @@ static int lio_vf_rep_phys_port_name(struct net_device *dev,
 static void lio_vf_rep_get_stats64(struct net_device *dev,
   struct rtnl_link_stats64 *stats64);
 static int lio_vf_rep_change_mtu(struct net_device *ndev, int new_mtu);
+static int lio_vf_get_port_parent_id(struct net_device *dev,
+struct netdev_phys_item_id *ppid);
 
 static const struct net_device_ops lio_vf_rep_ndev_ops = {
.ndo_open = lio_vf_rep_open,
@@ -47,6 +48,7 @@ static const struct net_device_ops lio_vf_rep_ndev_ops = {
.ndo_get_phys_port_name = lio_vf_rep_phys_port_name,
.ndo_get_stats64 = lio_vf_rep_get_stats64,
.ndo_change_mtu = lio_vf_rep_change_mtu,
+   .ndo_get_port_parent_id = lio_vf_get_port_parent_id,
 };
 
 static int
@@ -443,31 +445,19 @@ lio_vf_rep_pkt_xmit(struct sk_buff *skb, struct 
net_device *ndev)
return NETDEV_TX_OK;
 }
 
-static int
-lio_vf_rep_attr_get(struct net_device *dev, struct switchdev_attr *attr)
+static int lio_vf_get_port_parent_id(struct net_device *dev,
+struct netdev_phys_item_id *ppid)
 {
struct lio_vf_rep_desc *vf_rep = netdev_priv(dev);
struct net_device *parent_ndev = vf_rep->parent_ndev;
struct lio *lio = GET_LIO(parent_ndev);
 
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = ETH_ALEN;
-   ether_addr_copy(attr->u.ppid.id,
-   (void *)&lio->linfo.hw_addr + 2);
-   break;
-
-   default:
-   return -EOPNOTSUPP;
-

[PATCH net-next v3 08/12] rocker: Implement ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
mlxsw implements SWITCHDEV_ATTR_ID_PORT_PARENT_ID and we want to get rid
of switchdev_ops eventually, ease that migration by implementing a
ndo_get_port_parent_id() function which returns what
switchdev_port_attr_get() would do.

Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/rocker/rocker_main.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/rocker/rocker_main.c 
b/drivers/net/ethernet/rocker/rocker_main.c
index 62a205eba9f7..596f44dbfae1 100644
--- a/drivers/net/ethernet/rocker/rocker_main.c
+++ b/drivers/net/ethernet/rocker/rocker_main.c
@@ -2026,6 +2026,18 @@ static void rocker_port_neigh_destroy(struct net_device 
*dev,
err);
 }
 
+static int rocker_port_get_port_parent_id(struct net_device *dev,
+ struct netdev_phys_item_id *ppid)
+{
+   const struct rocker_port *rocker_port = netdev_priv(dev);
+   const struct rocker *rocker = rocker_port->rocker;
+
+   ppid->id_len = sizeof(rocker->hw.id);
+   memcpy(&ppid->id, &rocker->hw.id, ppid->id_len);
+
+   return 0;
+}
+
 static const struct net_device_ops rocker_port_netdev_ops = {
.ndo_open   = rocker_port_open,
.ndo_stop   = rocker_port_stop,
@@ -2035,6 +2047,7 @@ static const struct net_device_ops rocker_port_netdev_ops 
= {
.ndo_get_phys_port_name = rocker_port_get_phys_port_name,
.ndo_change_proto_down  = rocker_port_change_proto_down,
.ndo_neigh_destroy  = rocker_port_neigh_destroy,
+   .ndo_get_port_parent_id = rocker_port_get_port_parent_id,
 };
 
 /
@@ -2049,10 +2062,6 @@ static int rocker_port_attr_get(struct net_device *dev,
int err = 0;
 
switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = sizeof(rocker->hw.id);
-   memcpy(&attr->u.ppid.id, &rocker->hw.id, attr->u.ppid.id_len);
-   break;
case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
err = rocker_world_port_attr_bridge_flags_get(rocker_port,
  
&attr->u.brport_flags);
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next v3 07/12] nfp: Implement ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
NFP only supports SWITCHDEV_ATTR_ID_PORT_PARENT_ID, which makes it a
great candidate to be converted to use the ndo_get_port_parent_id() NDO
instead of implementing switchdev_port_attr_get().

Since NFP uses switchdev_port_same_parent_id() convert it to use
netdev_port_same_parent_id().

Signed-off-by: Florian Fainelli 
---
 .../ethernet/netronome/nfp/flower/action.c|  3 +--
 .../ethernet/netronome/nfp/nfp_net_common.c   |  4 +---
 .../net/ethernet/netronome/nfp/nfp_net_repr.c |  4 +---
 drivers/net/ethernet/netronome/nfp/nfp_port.c | 23 +--
 drivers/net/ethernet/netronome/nfp/nfp_port.h |  4 +++-
 5 files changed, 12 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/flower/action.c 
b/drivers/net/ethernet/netronome/nfp/flower/action.c
index 8d54b36afee8..7b217d7285c7 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/action.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/action.c
@@ -3,7 +3,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -137,7 +136,7 @@ nfp_fl_output(struct nfp_app *app, struct nfp_fl_output 
*output,
 
if (nfp_netdev_is_nfp_repr(in_dev)) {
/* Confirm ingress and egress are on same device. */
-   if (!switchdev_port_same_parent_id(in_dev, out_dev))
+   if (!netdev_port_same_parent_id(in_dev, out_dev))
return -EOPNOTSUPP;
}
 
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c 
b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index 7d2d4241498f..776f6c07701b 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -36,7 +36,6 @@
 #include 
 #include 
 
-#include 
 #include 
 
 #include "nfpcore/nfp_nsp.h"
@@ -3531,6 +3530,7 @@ const struct net_device_ops nfp_net_netdev_ops = {
.ndo_udp_tunnel_add = nfp_net_add_vxlan_port,
.ndo_udp_tunnel_del = nfp_net_del_vxlan_port,
.ndo_bpf= nfp_net_xdp,
+   .ndo_get_port_parent_id = nfp_port_get_port_parent_id,
 };
 
 /**
@@ -3815,8 +3815,6 @@ static void nfp_net_netdev_init(struct nfp_net *nn)
netdev->netdev_ops = &nfp_net_netdev_ops;
netdev->watchdog_timeo = msecs_to_jiffies(5 * 1000);
 
-   SWITCHDEV_SET_OPS(netdev, &nfp_port_switchdev_ops);
-
/* MTU range: 68 - hw-specific max */
netdev->min_mtu = ETH_MIN_MTU;
netdev->max_mtu = nn->max_mtu;
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c 
b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
index 69d7aebda09b..62839807e21e 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
@@ -5,7 +5,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "nfpcore/nfp_cpp.h"
 #include "nfpcore/nfp_nsp.h"
@@ -273,6 +272,7 @@ const struct net_device_ops nfp_repr_netdev_ops = {
.ndo_fix_features   = nfp_repr_fix_features,
.ndo_set_features   = nfp_port_set_features,
.ndo_set_mac_address= eth_mac_addr,
+   .ndo_get_port_parent_id = nfp_port_get_port_parent_id,
 };
 
 void
@@ -336,8 +336,6 @@ int nfp_repr_init(struct nfp_app *app, struct net_device 
*netdev,
 
netdev->max_mtu = pf_netdev->max_mtu;
 
-   SWITCHDEV_SET_OPS(netdev, &nfp_port_switchdev_ops);
-
/* Set features the lower device can support with representors */
if (repr_cap & NFP_NET_CFG_CTRL_LIVE_ADDR)
netdev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_port.c 
b/drivers/net/ethernet/netronome/nfp/nfp_port.c
index 86bc149ca231..b9aa7eb99067 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_port.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_port.c
@@ -31,34 +31,23 @@ struct nfp_port *nfp_port_from_netdev(struct net_device 
*netdev)
return NULL;
 }
 
-static int
-nfp_port_attr_get(struct net_device *netdev, struct switchdev_attr *attr)
+int nfp_port_get_port_parent_id(struct net_device *netdev,
+   struct netdev_phys_item_id *ppid)
 {
struct nfp_port *port;
+   const u8 *serial;
 
port = nfp_port_from_netdev(netdev);
if (!port)
return -EOPNOTSUPP;
 
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID: {
-   const u8 *serial;
-   /* N.B: attr->u.ppid.id is binary data */
-   attr->u.ppid.id_len = nfp_cpp_serial(port->app->cpp, &serial);
-   memcpy(&attr->u.ppid.id, serial, attr->u.ppid.id_len);
-   break;
-   }
-   default:
-   return -EOPNOTSUPP;
-   }
+   /* N.B: attr->u.ppid.id is binary data */
+   ppid->id_len = nfp_cpp_serial(port->app->cpp, &serial);
+   memcpy(&ppid->id, serial, ppid->id_len);
 
return 0;
 }
 
-const struct switchdev_ops nfp_port_swit

[PATCH net-next v3 11/12] net: dsa: Implement ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
DSA implements SWITCHDEV_ATTR_ID_PORT_PARENT_ID and we want to get rid
of switchdev_ops eventually, ease that migration by implementing a
ndo_get_port_parent_id() function which returns what
switchdev_port_attr_get() would do.

Signed-off-by: Florian Fainelli 
---
 net/dsa/slave.c | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 91de3a663226..70395a0ae52e 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -362,18 +362,23 @@ static int dsa_slave_port_obj_del(struct net_device *dev,
return err;
 }
 
-static int dsa_slave_port_attr_get(struct net_device *dev,
-  struct switchdev_attr *attr)
+static int dsa_slave_get_port_parent_id(struct net_device *dev,
+   struct netdev_phys_item_id *ppid)
 {
struct dsa_port *dp = dsa_slave_to_port(dev);
struct dsa_switch *ds = dp->ds;
struct dsa_switch_tree *dst = ds->dst;
 
+   ppid->id_len = sizeof(dst->index);
+   memcpy(&ppid->id, &dst->index, ppid->id_len);
+
+   return 0;
+}
+
+static int dsa_slave_port_attr_get(struct net_device *dev,
+  struct switchdev_attr *attr)
+{
switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = sizeof(dst->index);
-   memcpy(&attr->u.ppid.id, &dst->index, attr->u.ppid.id_len);
-   break;
case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT:
attr->u.brport_flags_support = 0;
break;
@@ -1046,6 +1051,7 @@ static const struct net_device_ops dsa_slave_netdev_ops = 
{
.ndo_get_phys_port_name = dsa_slave_get_phys_port_name,
.ndo_setup_tc   = dsa_slave_setup_tc,
.ndo_get_stats64= dsa_slave_get_stats64,
+   .ndo_get_port_parent_id = dsa_slave_get_port_parent_id,
 };
 
 static const struct switchdev_ops dsa_slave_switchdev_ops = {
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next v3 09/12] netdevsim: Implement ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
netdevsim only supports SWITCHDEV_ATTR_ID_PORT_PARENT_ID, which makes it a
great candidate to be converted to use the ndo_get_port_parent_id() NDO
instead of implementing switchdev_port_attr_get().

Signed-off-by: Florian Fainelli 
---
 drivers/net/netdevsim/netdev.c | 23 ++-
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c
index 8d8e2b3f263e..75a50b59cb8f 100644
--- a/drivers/net/netdevsim/netdev.c
+++ b/drivers/net/netdevsim/netdev.c
@@ -22,7 +22,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "netdevsim.h"
 
@@ -148,26 +147,16 @@ static struct device_type nsim_dev_type = {
.release = nsim_dev_release,
 };
 
-static int
-nsim_port_attr_get(struct net_device *dev, struct switchdev_attr *attr)
+static int nsim_get_port_parent_id(struct net_device *dev,
+  struct netdev_phys_item_id *ppid)
 {
struct netdevsim *ns = netdev_priv(dev);
 
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = sizeof(ns->sdev->switch_id);
-   memcpy(&attr->u.ppid.id, &ns->sdev->switch_id,
-  attr->u.ppid.id_len);
-   return 0;
-   default:
-   return -EOPNOTSUPP;
-   }
+   ppid->id_len = sizeof(ns->sdev->switch_id);
+   memcpy(&ppid->id, &ns->sdev->switch_id, ppid->id_len);
+   return 0;
 }
 
-static const struct switchdev_ops nsim_switchdev_ops = {
-   .switchdev_port_attr_get= nsim_port_attr_get,
-};
-
 static int nsim_init(struct net_device *dev)
 {
char sdev_ddir_name[10], sdev_link_name[32];
@@ -214,7 +203,6 @@ static int nsim_init(struct net_device *dev)
goto err_bpf_uninit;
 
SET_NETDEV_DEV(dev, &ns->dev);
-   SWITCHDEV_SET_OPS(dev, &nsim_switchdev_ops);
 
err = nsim_devlink_setup(ns);
if (err)
@@ -493,6 +481,7 @@ static const struct net_device_ops nsim_netdev_ops = {
.ndo_setup_tc   = nsim_setup_tc,
.ndo_set_features   = nsim_set_features,
.ndo_bpf= nsim_bpf,
+   .ndo_get_port_parent_id = nsim_get_port_parent_id,
 };
 
 static void nsim_setup(struct net_device *dev)
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next v3 06/12] mscc: ocelot: Implement ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
Ocelot only supports SWITCHDEV_ATTR_ID_PORT_PARENT_ID as a valid
switchdev attribute getter, convert it to use ndo_get_port_parent_id()
and get rid of the switchdev_ops::switchdev_port_attr_get altogether.

Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/mscc/ocelot.c | 33 --
 1 file changed, 13 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot.c 
b/drivers/net/ethernet/mscc/ocelot.c
index c6a575eb0ff5..195306d05bcd 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -916,6 +916,18 @@ static int ocelot_set_features(struct net_device *dev,
return 0;
 }
 
+static int ocelot_get_port_parent_id(struct net_device *dev,
+struct netdev_phys_item_id *ppid)
+{
+   struct ocelot_port *ocelot_port = netdev_priv(dev);
+   struct ocelot *ocelot = ocelot_port->ocelot;
+
+   ppid->id_len = sizeof(ocelot->base_mac);
+   memcpy(&ppid->id, &ocelot->base_mac, ppid->id_len);
+
+   return 0;
+}
+
 static const struct net_device_ops ocelot_port_netdev_ops = {
.ndo_open   = ocelot_port_open,
.ndo_stop   = ocelot_port_stop,
@@ -930,6 +942,7 @@ static const struct net_device_ops ocelot_port_netdev_ops = 
{
.ndo_vlan_rx_add_vid= ocelot_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid   = ocelot_vlan_rx_kill_vid,
.ndo_set_features   = ocelot_set_features,
+   .ndo_get_port_parent_id = ocelot_get_port_parent_id,
 };
 
 static void ocelot_get_strings(struct net_device *netdev, u32 sset, u8 *data)
@@ -1013,25 +1026,6 @@ static const struct ethtool_ops ocelot_ethtool_ops = {
.set_link_ksettings = phy_ethtool_set_link_ksettings,
 };
 
-static int ocelot_port_attr_get(struct net_device *dev,
-   struct switchdev_attr *attr)
-{
-   struct ocelot_port *ocelot_port = netdev_priv(dev);
-   struct ocelot *ocelot = ocelot_port->ocelot;
-
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = sizeof(ocelot->base_mac);
-   memcpy(&attr->u.ppid.id, &ocelot->base_mac,
-  attr->u.ppid.id_len);
-   break;
-   default:
-   return -EOPNOTSUPP;
-   }
-
-   return 0;
-}
-
 static int ocelot_port_attr_stp_state_set(struct ocelot_port *ocelot_port,
  struct switchdev_trans *trans,
  u8 state)
@@ -1331,7 +1325,6 @@ static int ocelot_port_obj_del(struct net_device *dev,
 }
 
 static const struct switchdev_ops ocelot_port_switchdev_ops = {
-   .switchdev_port_attr_get= ocelot_port_attr_get,
.switchdev_port_attr_set= ocelot_port_attr_set,
 };
 
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next v3 05/12] mlxsw: Implement ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
mlxsw implements SWITCHDEV_ATTR_ID_PORT_PARENT_ID and we want to get rid
of switchdev_ops eventually, ease that migration by implementing a
ndo_get_port_parent_id() function which returns what
switchdev_port_attr_get() would do.

Signed-off-by: Florian Fainelli 
---
 .../net/ethernet/mellanox/mlxsw/spectrum.c| 13 +++
 .../mellanox/mlxsw/spectrum_switchdev.c   |  5 ---
 .../net/ethernet/mellanox/mlxsw/switchx2.c| 36 +++
 3 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index a88169738b4a..8dd808b7f931 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -1700,6 +1700,18 @@ static int mlxsw_sp_set_features(struct net_device *dev,
   mlxsw_sp_feature_hw_tc);
 }
 
+static int mlxsw_sp_port_get_port_parent_id(struct net_device *dev,
+   struct netdev_phys_item_id *ppid)
+{
+   struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
+   struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
+
+   ppid->id_len = sizeof(mlxsw_sp->base_mac);
+   memcpy(&ppid->id, &mlxsw_sp->base_mac, ppid->id_len);
+
+   return 0;
+}
+
 static const struct net_device_ops mlxsw_sp_port_netdev_ops = {
.ndo_open   = mlxsw_sp_port_open,
.ndo_stop   = mlxsw_sp_port_stop,
@@ -1715,6 +1727,7 @@ static const struct net_device_ops 
mlxsw_sp_port_netdev_ops = {
.ndo_vlan_rx_kill_vid   = mlxsw_sp_port_kill_vid,
.ndo_get_phys_port_name = mlxsw_sp_port_get_phys_port_name,
.ndo_set_features   = mlxsw_sp_set_features,
+   .ndo_get_port_parent_id = mlxsw_sp_port_get_port_parent_id,
 };
 
 static void mlxsw_sp_port_get_drvinfo(struct net_device *dev,
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index a4a9fe992193..95e37de3e48f 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -451,11 +451,6 @@ static int mlxsw_sp_port_attr_get(struct net_device *dev,
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
 
switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = sizeof(mlxsw_sp->base_mac);
-   memcpy(&attr->u.ppid.id, &mlxsw_sp->base_mac,
-  attr->u.ppid.id_len);
-   break;
case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
mlxsw_sp_port_bridge_flags_get(mlxsw_sp->bridge, attr->orig_dev,
   &attr->u.brport_flags);
diff --git a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c 
b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
index 2d4f213e154d..3814ba8af517 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
@@ -390,6 +390,18 @@ static int mlxsw_sx_port_get_phys_port_name(struct 
net_device *dev, char *name,
  name, len);
 }
 
+static int mlxsw_sx_port_get_port_parent_id(struct net_device *dev,
+   struct netdev_phys_item_id *ppid)
+{
+   struct mlxsw_sx_port *mlxsw_sx_port = netdev_priv(dev);
+   struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx;
+
+   ppid->id_len = sizeof(mlxsw_sx->hw_id);
+   memcpy(&ppid->id, &mlxsw_sx->hw_id, ppid->id_len);
+
+   return 0;
+}
+
 static const struct net_device_ops mlxsw_sx_port_netdev_ops = {
.ndo_open   = mlxsw_sx_port_open,
.ndo_stop   = mlxsw_sx_port_stop,
@@ -397,6 +409,7 @@ static const struct net_device_ops mlxsw_sx_port_netdev_ops 
= {
.ndo_change_mtu = mlxsw_sx_port_change_mtu,
.ndo_get_stats64= mlxsw_sx_port_get_stats64,
.ndo_get_phys_port_name = mlxsw_sx_port_get_phys_port_name,
+   .ndo_get_port_parent_id = mlxsw_sx_port_get_port_parent_id,
 };
 
 static void mlxsw_sx_port_get_drvinfo(struct net_device *dev,
@@ -901,28 +914,6 @@ static const struct ethtool_ops mlxsw_sx_port_ethtool_ops 
= {
.set_link_ksettings = mlxsw_sx_port_set_link_ksettings,
 };
 
-static int mlxsw_sx_port_attr_get(struct net_device *dev,
- struct switchdev_attr *attr)
-{
-   struct mlxsw_sx_port *mlxsw_sx_port = netdev_priv(dev);
-   struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx;
-
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = sizeof(mlxsw_sx->hw_id);
-   memcpy(&attr->u.ppid.id, &mlxsw_sx->hw_id, attr->u.ppid.id_len);
-   break;
-   default:
-   return -EOPNOTSUPP;
-   }
-
-   return 0;
-}
-
-static const struct s

[PATCH net-next v3 02/12] bnxt: Implement ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
BNXT only supports SWITCHDEV_ATTR_ID_PORT_PARENT_ID, which makes it a
great candidate to be converted to use the ndo_get_port_parent_id() NDO
instead of implementing switchdev_port_attr_get(). The conversion is
straight forward here since the PF and VF code use the same getter.

Since bnxt makes uses of switchdev_port_same_parent_id() convert it to
use netdev_port_same_parent_id().

Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 28 ++-
 drivers/net/ethernet/broadcom/bnxt/bnxt.h |  4 +--
 drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c  |  3 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | 12 +++-
 4 files changed, 16 insertions(+), 31 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 6a512871176b..1c2987c3d708 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -9981,8 +9981,11 @@ static int bnxt_get_phys_port_name(struct net_device 
*dev, char *buf,
return 0;
 }
 
-int bnxt_port_attr_get(struct bnxt *bp, struct switchdev_attr *attr)
+int bnxt_get_port_parent_id(struct net_device *dev,
+   struct netdev_phys_item_id *ppid)
 {
+   struct bnxt *bp = netdev_priv(dev);
+
if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV)
return -EOPNOTSUPP;
 
@@ -9990,27 +9993,12 @@ int bnxt_port_attr_get(struct bnxt *bp, struct 
switchdev_attr *attr)
if (!BNXT_PF(bp))
return -EOPNOTSUPP;
 
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = sizeof(bp->switch_id);
-   memcpy(attr->u.ppid.id, bp->switch_id, attr->u.ppid.id_len);
-   break;
-   default:
-   return -EOPNOTSUPP;
-   }
-   return 0;
-}
+   ppid->id_len = sizeof(bp->switch_id);
+   memcpy(ppid->id, bp->switch_id, ppid->id_len);
 
-static int bnxt_swdev_port_attr_get(struct net_device *dev,
-   struct switchdev_attr *attr)
-{
-   return bnxt_port_attr_get(netdev_priv(dev), attr);
+   return 0;
 }
 
-static const struct switchdev_ops bnxt_switchdev_ops = {
-   .switchdev_port_attr_get= bnxt_swdev_port_attr_get
-};
-
 static const struct net_device_ops bnxt_netdev_ops = {
.ndo_open   = bnxt_open,
.ndo_start_xmit = bnxt_start_xmit,
@@ -10042,6 +10030,7 @@ static const struct net_device_ops bnxt_netdev_ops = {
.ndo_bpf= bnxt_xdp,
.ndo_bridge_getlink = bnxt_bridge_getlink,
.ndo_bridge_setlink = bnxt_bridge_setlink,
+   .ndo_get_port_parent_id = bnxt_get_port_parent_id,
.ndo_get_phys_port_name = bnxt_get_phys_port_name
 };
 
@@ -10400,7 +10389,6 @@ static int bnxt_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
dev->netdev_ops = &bnxt_netdev_ops;
dev->watchdog_timeo = BNXT_TX_TIMEOUT;
dev->ethtool_ops = &bnxt_ethtool_ops;
-   SWITCHDEV_SET_OPS(dev, &bnxt_switchdev_ops);
pci_set_drvdata(pdev, dev);
 
rc = bnxt_alloc_hwrm_resources(bp);
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h 
b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 5c886a700bcc..17554d4be651 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -22,7 +22,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -1795,7 +1794,8 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, 
bool sh, int tcs,
 int bnxt_setup_mq_tc(struct net_device *dev, u8 tc);
 int bnxt_get_max_rings(struct bnxt *, int *, int *, bool);
 int bnxt_restore_pf_fw_resources(struct bnxt *bp);
-int bnxt_port_attr_get(struct bnxt *bp, struct switchdev_attr *attr);
+int bnxt_get_port_parent_id(struct net_device *dev,
+   struct netdev_phys_item_id *ppid);
 void bnxt_dim_work(struct work_struct *work);
 int bnxt_hwrm_set_ring_coal(struct bnxt *bp, struct bnxt_napi *bnapi);
 
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
index c683b5e96b1d..170d2fbbb91b 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -45,7 +46,7 @@ static u16 bnxt_flow_get_dst_fid(struct bnxt *pf_bp, struct 
net_device *dev)
struct bnxt *bp;
 
/* check if dev belongs to the same switch */
-   if (!switchdev_port_same_parent_id(pf_bp->dev, dev)) {
+   if (!netdev_port_same_parent_id(pf_bp->dev, dev)) {
netdev_info(pf_bp->dev, "dev(ifindex=%d) not on same switch",
dev->ifindex);
return BNXT_FID_INVALID;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c 
b/drivers/net/ethernet/bro

[PATCH net-next v3 04/12] net/mlx5e: Implement ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
mlx5e only supports SWITCHDEV_ATTR_ID_PORT_PARENT_ID, which makes it a
great candidate to be converted to use the ndo_get_port_parent_id() NDO
instead of implementing switchdev_port_attr_get().

Since mlx5e makes use of switchdev_port_parent_id() convert it to use
netdev_port_same_parent_id().

Signed-off-by: Florian Fainelli 
---
 .../ethernet/mellanox/mlx5/core/en/tc_tun.c   |  2 +-
 .../net/ethernet/mellanox/mlx5/core/en_rep.c  | 31 +++
 .../net/ethernet/mellanox/mlx5/core/en_tc.c   |  5 ++-
 3 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
index 046948ead152..19dc4a963b90 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
@@ -25,7 +25,7 @@ static int get_route_and_out_devs(struct mlx5e_priv *priv,
/* if the egress device isn't on the same HW e-switch or
 * it's a LAG device, use the uplink
 */
-   if (!switchdev_port_same_parent_id(priv->netdev, dev) ||
+   if (!netdev_port_same_parent_id(priv->netdev, dev) ||
dst_is_lag_dev) {
*route_dev = uplink_dev;
*out_dev = *route_dev;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 5d2e0c2f6624..0b1988b330f3 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -381,7 +381,8 @@ static const struct ethtool_ops 
mlx5e_uplink_rep_ethtool_ops = {
.set_pauseparam= mlx5e_uplink_rep_set_pauseparam,
 };
 
-static int mlx5e_attr_get(struct net_device *dev, struct switchdev_attr *attr)
+static int mlx5e_rep_get_port_parent_id(struct net_device *dev,
+   struct netdev_phys_item_id *ppid)
 {
struct mlx5e_priv *priv = netdev_priv(dev);
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
@@ -398,20 +399,14 @@ static int mlx5e_attr_get(struct net_device *dev, struct 
switchdev_attr *attr)
uplink_priv = netdev_priv(uplink_dev);
}
 
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = ETH_ALEN;
-   if (uplink_upper && mlx5_lag_is_sriov(uplink_priv->mdev)) {
-   ether_addr_copy(attr->u.ppid.id, 
uplink_upper->dev_addr);
-   } else {
-   struct mlx5e_rep_priv *rpriv = priv->ppriv;
-   struct mlx5_eswitch_rep *rep = rpriv->rep;
+   ppid->id_len = ETH_ALEN;
+   if (uplink_upper && mlx5_lag_is_sriov(uplink_priv->mdev)) {
+   ether_addr_copy(ppid->id, uplink_upper->dev_addr);
+   } else {
+   struct mlx5e_rep_priv *rpriv = priv->ppriv;
+   struct mlx5_eswitch_rep *rep = rpriv->rep;
 
-   ether_addr_copy(attr->u.ppid.id, rep->hw_id);
-   }
-   break;
-   default:
-   return -EOPNOTSUPP;
+   ether_addr_copy(ppid->id, rep->hw_id);
}
 
return 0;
@@ -1284,10 +1279,6 @@ static int mlx5e_uplink_rep_set_vf_vlan(struct 
net_device *dev, int vf, u16 vlan
return 0;
 }
 
-static const struct switchdev_ops mlx5e_rep_switchdev_ops = {
-   .switchdev_port_attr_get= mlx5e_attr_get,
-};
-
 static const struct net_device_ops mlx5e_netdev_ops_vf_rep = {
.ndo_open= mlx5e_vf_rep_open,
.ndo_stop= mlx5e_vf_rep_close,
@@ -1298,6 +1289,7 @@ static const struct net_device_ops 
mlx5e_netdev_ops_vf_rep = {
.ndo_has_offload_stats   = mlx5e_rep_has_offload_stats,
.ndo_get_offload_stats   = mlx5e_rep_get_offload_stats,
.ndo_change_mtu  = mlx5e_vf_rep_change_mtu,
+   .ndo_get_port_parent_id  = mlx5e_rep_get_port_parent_id,
 };
 
 static const struct net_device_ops mlx5e_netdev_ops_uplink_rep = {
@@ -1319,6 +1311,7 @@ static const struct net_device_ops 
mlx5e_netdev_ops_uplink_rep = {
.ndo_get_vf_config   = mlx5e_get_vf_config,
.ndo_get_vf_stats= mlx5e_get_vf_stats,
.ndo_set_vf_vlan = mlx5e_uplink_rep_set_vf_vlan,
+   .ndo_get_port_parent_id  = mlx5e_rep_get_port_parent_id,
 };
 
 bool mlx5e_eswitch_rep(struct net_device *netdev)
@@ -1393,8 +1386,6 @@ static void mlx5e_build_rep_netdev(struct net_device 
*netdev)
netdev->watchdog_timeo= 15 * HZ;
 
 
-   netdev->switchdev_ops = &mlx5e_rep_switchdev_ops;
-
netdev->features |= NETIF_F_HW_TC | NETIF_F_NETNS_LOCAL;
netdev->hw_features  |= NETIF_F_HW_TC;
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 74159d39dd66..098b28feba0c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/cor

[PATCH net-next v3 00/12] net: Introduce ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
Hi all,

Based on discussion with Ido and feedback from Jakub there are clearly
two classes of users that implement SWITCHDEV_ATTR_ID_PORT_PARENT_ID:

- PF/VF drivers which typically only implement return the port's parent
  ID, yet have to implement switchdev_port_attr_get() just for that

- Ethernet switch drivers: mlxsw, ocelot, DSA, etc. which implement more
  attributes which we want to be able to eventually veto in the context
  of the caller, thus making them candidates for using a blocking notifier
  chain

Changes in v3:

- keep ethsw's switchdev_ops assignment
- remove inclusion of net/switchdev.h in netdevsim which is no longer
  necesary

Changes in v2:

- resolved build failures spotted by kbuild test robot
- added helpers functions into the core network device layer:
  dev_get_port_parent_id() and netdev_port_same_parent_id();
- added support for recursion to lower devices

Changes from RFC:

- introduce a ndo_get_port_parent_id() and convert all relevant drivers
  to use it

- get rid of SWITCHDEV_ATTR_ID_PORT_PARENT_ID

A subsequent set of patches will convert switchdev_port_attr_set() to
use a blocking notifier call, and still get rid of
switchdev_port_attr_get() altogether.

Florian Fainelli (12):
  net: Introduce ndo_get_port_parent_id()
  bnxt: Implement ndo_get_port_parent_id()
  liquidio: Implement ndo_get_port_parent_id()
  net/mlx5e: Implement ndo_get_port_parent_id()
  mlxsw: Implement ndo_get_port_parent_id()
  mscc: ocelot: Implement ndo_get_port_parent_id()
  nfp: Implement ndo_get_port_parent_id()
  rocker: Implement ndo_get_port_parent_id()
  netdevsim: Implement ndo_get_port_parent_id()
  staging: fsl-dpaa2: ethsw: Implement ndo_get_port_parent_id()
  net: dsa: Implement ndo_get_port_parent_id()
  net: Get rid of SWITCHDEV_ATTR_ID_PORT_PARENT_ID

 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 28 +++--
 drivers/net/ethernet/broadcom/bnxt/bnxt.h |  4 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c  |  3 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | 12 ++--
 .../net/ethernet/cavium/liquidio/lio_main.c   | 22 ++-
 .../net/ethernet/cavium/liquidio/lio_vf_rep.c | 25 +++-
 .../ethernet/mellanox/mlx5/core/en/tc_tun.c   |  2 +-
 .../net/ethernet/mellanox/mlx5/core/en_rep.c  | 31 --
 .../net/ethernet/mellanox/mlx5/core/en_tc.c   |  5 +-
 .../net/ethernet/mellanox/mlxsw/spectrum.c| 13 +
 .../mellanox/mlxsw/spectrum_switchdev.c   |  5 --
 .../net/ethernet/mellanox/mlxsw/switchx2.c| 36 +---
 drivers/net/ethernet/mscc/ocelot.c| 33 +--
 .../ethernet/netronome/nfp/flower/action.c|  3 +-
 .../ethernet/netronome/nfp/nfp_net_common.c   |  4 +-
 .../net/ethernet/netronome/nfp/nfp_net_repr.c |  4 +-
 drivers/net/ethernet/netronome/nfp/nfp_port.c | 23 ++--
 drivers/net/ethernet/netronome/nfp/nfp_port.h |  4 +-
 drivers/net/ethernet/rocker/rocker_main.c | 17 --
 drivers/net/netdevsim/netdev.c| 23 ++--
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c   | 16 --
 include/linux/netdevice.h |  9 +++
 include/net/switchdev.h   | 11 
 net/bridge/br_switchdev.c | 11 ++--
 net/core/dev.c| 57 +++
 net/core/net-sysfs.c  | 12 +---
 net/core/rtnetlink.c  | 14 ++---
 net/dsa/slave.c   | 18 --
 net/ipv4/ipmr.c   | 14 ++---
 net/switchdev/switchdev.c | 20 ---
 30 files changed, 219 insertions(+), 260 deletions(-)

-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next v3 01/12] net: Introduce ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
In preparation for getting rid of switchdev_ops, create a dedicated NDO
operation for getting the port's parent identifier. There are
essentially two classes of drivers that need to implement getting the
port's parent ID which are VF/PF drivers with a built-in switch, and
pure switchdev drivers such as mlxsw, ocelot, dsa etc.

We introduce a helper function: dev_get_port_parent_id() which supports
recursing into the lower devices to obtain the first port's parent ID.

Convert the bridge, core and ipv4 multicast routing code to check for
such ndo_get_port_parent_id() and call the helper functino when valid
before falling back to switchdev_port_attr_get(). This will allow us to
convert all relevant drivers in one go instead of having to implement
both switchdev_port_attr_get() and ndo_get_port_parent_id() operations,
then get rid of switchdev_port_attr_get().

Signed-off-by: Florian Fainelli 
---
 include/linux/netdevice.h |  9 +++
 net/bridge/br_switchdev.c |  9 +--
 net/core/dev.c| 57 +++
 net/core/net-sysfs.c  |  7 -
 net/core/rtnetlink.c  |  6 -
 net/ipv4/ipmr.c   |  8 +-
 6 files changed, 91 insertions(+), 5 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index ba57d0ba425e..1d95e634f3fe 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1188,6 +1188,10 @@ struct dev_ifalias {
  * not implement this, it is assumed that the hw is not able to have
  * multiple net devices on single physical port.
  *
+ * int (*ndo_get_port_parent_id)(struct net_device *dev,
+ *  struct netdev_phys_item_id *ppid)
+ * Called to get the parent ID of the physical port of this device.
+ *
  * void (*ndo_udp_tunnel_add)(struct net_device *dev,
  *   struct udp_tunnel_info *ti);
  * Called by UDP tunnel to notify a driver about the UDP port and socket
@@ -1412,6 +1416,8 @@ struct net_device_ops {
  bool new_carrier);
int (*ndo_get_phys_port_id)(struct net_device *dev,
struct 
netdev_phys_item_id *ppid);
+   int (*ndo_get_port_parent_id)(struct net_device 
*dev,
+ struct 
netdev_phys_item_id *ppid);
int (*ndo_get_phys_port_name)(struct net_device 
*dev,
  char *name, size_t 
len);
void(*ndo_udp_tunnel_add)(struct net_device *dev,
@@ -3651,6 +3657,9 @@ int dev_get_phys_port_id(struct net_device *dev,
 struct netdev_phys_item_id *ppid);
 int dev_get_phys_port_name(struct net_device *dev,
   char *name, size_t len);
+int dev_get_port_parent_id(struct net_device *dev,
+  struct netdev_phys_item_id *ppid, bool recurse);
+bool netdev_port_same_parent_id(struct net_device *a, struct net_device *b);
 int dev_change_proto_down(struct net_device *dev, bool proto_down);
 struct sk_buff *validate_xmit_skb_list(struct sk_buff *skb, struct net_device 
*dev, bool *again);
 struct sk_buff *dev_hard_start_xmit(struct sk_buff *skb, struct net_device 
*dev,
diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
index 4d2b9eb7604a..06b0ae44585f 100644
--- a/net/bridge/br_switchdev.c
+++ b/net/bridge/br_switchdev.c
@@ -14,7 +14,8 @@ static int br_switchdev_mark_get(struct net_bridge *br, 
struct net_device *dev)
 
/* dev is yet to be added to the port list. */
list_for_each_entry(p, &br->port_list, list) {
-   if (switchdev_port_same_parent_id(dev, p->dev))
+   if (netdev_port_same_parent_id(dev, p->dev) ||
+   switchdev_port_same_parent_id(dev, p->dev))
return p->offload_fwd_mark;
}
 
@@ -23,6 +24,7 @@ static int br_switchdev_mark_get(struct net_bridge *br, 
struct net_device *dev)
 
 int nbp_switchdev_mark_set(struct net_bridge_port *p)
 {
+   const struct net_device_ops *ops = p->dev->netdev_ops;
struct switchdev_attr attr = {
.orig_dev = p->dev,
.id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID,
@@ -31,7 +33,10 @@ int nbp_switchdev_mark_set(struct net_bridge_port *p)
 
ASSERT_RTNL();
 
-   err = switchdev_port_attr_get(p->dev, &attr);
+   if (ops->ndo_get_port_parent_id)
+   err = dev_get_port_parent_id(p->dev, &attr.u.ppid, true);
+   else
+   err = switchdev_port_attr_get(p->dev, &attr);
if (err) {
if (err == -EOPNOTSUPP)
return 0;
diff --git a/net/core/dev.c b/net/core/dev.c
index bfa4be42afff..8c6d5cf8a308 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -7877,6 +7877,63 @@ int dev_get_phys_port_name(struct net_device *de

Re: [PATCH 2/2] staging: android: ashmem: Don't allow range_alloc() to fail.

2019-02-05 Thread Tetsuo Handa
Joel Fernandes wrote:
> On Tue, Feb 05, 2019 at 07:28:41PM +0900, Tetsuo Handa wrote:
> > ashmem_pin() is calling range_shrink() without checking whether
> > range_alloc() succeeded. Since memory allocation fault injection might
> > force range_alloc() to fail while range_alloc() is called for only once
> > for one ioctl() request, make range_alloc() not to fail.
> 
> Why does this not need to fail? I am worried your change will introduce
> unwanted endless looping in the kernel instead of gracefully failing a
> pin/unpin request.

This patch won't introduce endless looping in the kernel, due to a rule called

  The "too small to fail" memory-allocation rule
  https://lwn.net/Articles/627419/

. In short, memory allocation by range_alloc() might fail only if current thread
was killed by the OOM killer or memory allocation fault injection mechanism
forced it to fail. And this patch helps doing fuzzing test with minimal changes.

> 
> Unless there is a good reason, I suggest to drop this patch from the series;
> but let us discuss more if you want.

We can allocate memory for range_alloc() before holding ashmem_mutex at
ashmem_pin_unpin() if you don't want to use __GFP_NOFAIL. It is better to
avoid memory allocation with ashmem_mutex because ashmem_mutex is held by
shrinker function. But given that this module is going to be replaced shortly,
does it worth moving the memory allocation to the caller?

> 
> thanks,
> 
>  - Joel
> 
> From the docs:
> __GFP_NOFAIL - Indicate that this allocation is in no way allowed to fail 
> (think twice before using).
> 

The "too small to fail" memory-allocation rule already made almost 
__GFP_NOFAIL. :-)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH net-next v2 10/12] staging: fsl-dpaa2: ethsw: Implement ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
On 2/5/19 2:13 PM, Florian Fainelli wrote:
> ethsw implements SWITCHDEV_ATTR_ID_PORT_PARENT_ID and we want to get rid
> of switchdev_ops eventually, ease that migration by implementing a
> ndo_get_port_parent_id() function which returns what
> switchdev_port_attr_get() would do.
> 
> Signed-off-by: Florian Fainelli 
> ---
>  drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 17 -
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
> b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
> index daabaceeea52..622f32377b91 100644
> --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
> +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
> @@ -505,6 +505,17 @@ static netdev_tx_t port_dropframe(struct sk_buff *skb,
>   return NETDEV_TX_OK;
>  }
>  
> +static int swdev_get_port_parent_id(struct net_device *dev,
> + struct netdev_phys_item_id *ppid)
> +{
> + struct ethsw_port_priv *port_priv = netdev_priv(dev);
> +
> + ppid->id_len = 1;
> + ppid->id[0] = port_priv->ethsw_data->dev_id;
> +
> + return 0;
> +}
> +
>  static const struct net_device_ops ethsw_port_ops = {
>   .ndo_open   = port_open,
>   .ndo_stop   = port_stop,
> @@ -515,6 +526,7 @@ static const struct net_device_ops ethsw_port_ops = {
>   .ndo_get_offload_stats  = port_get_offload_stats,
>  
>   .ndo_start_xmit = port_dropframe,
> + .ndo_get_port_parent_id = swdev_get_port_parent_id,
>  };
>  
>  static void ethsw_links_state_update(struct ethsw_core *ethsw)
> @@ -634,10 +646,6 @@ static int swdev_port_attr_get(struct net_device *netdev,
>   struct ethsw_port_priv *port_priv = netdev_priv(netdev);
>  
>   switch (attr->id) {
> - case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
> - attr->u.ppid.id_len = 1;
> - attr->u.ppid.id[0] = port_priv->ethsw_data->dev_id;
> - break;
>   case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
>   attr->u.brport_flags =
>   (port_priv->ethsw_data->learning ? BR_LEARNING : 0) |
> @@ -1434,7 +1442,6 @@ static int ethsw_probe_port(struct ethsw_core *ethsw, 
> u16 port_idx)
>   SET_NETDEV_DEV(port_netdev, dev);
>   port_netdev->netdev_ops = ðsw_port_ops;
>   port_netdev->ethtool_ops = ðsw_port_ethtool_ops;
> - port_netdev->switchdev_ops = ðsw_port_switchdev_ops;

This hunk should not be removed, I will respin a new version after
getting feedback.
-- 
Florian
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next v2 05/12] mlxsw: Implement ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
mlxsw implements SWITCHDEV_ATTR_ID_PORT_PARENT_ID and we want to get rid
of switchdev_ops eventually, ease that migration by implementing a
ndo_get_port_parent_id() function which returns what
switchdev_port_attr_get() would do.

Signed-off-by: Florian Fainelli 
---
 .../net/ethernet/mellanox/mlxsw/spectrum.c| 13 +++
 .../mellanox/mlxsw/spectrum_switchdev.c   |  5 ---
 .../net/ethernet/mellanox/mlxsw/switchx2.c| 36 +++
 3 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index a88169738b4a..8dd808b7f931 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -1700,6 +1700,18 @@ static int mlxsw_sp_set_features(struct net_device *dev,
   mlxsw_sp_feature_hw_tc);
 }
 
+static int mlxsw_sp_port_get_port_parent_id(struct net_device *dev,
+   struct netdev_phys_item_id *ppid)
+{
+   struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
+   struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
+
+   ppid->id_len = sizeof(mlxsw_sp->base_mac);
+   memcpy(&ppid->id, &mlxsw_sp->base_mac, ppid->id_len);
+
+   return 0;
+}
+
 static const struct net_device_ops mlxsw_sp_port_netdev_ops = {
.ndo_open   = mlxsw_sp_port_open,
.ndo_stop   = mlxsw_sp_port_stop,
@@ -1715,6 +1727,7 @@ static const struct net_device_ops 
mlxsw_sp_port_netdev_ops = {
.ndo_vlan_rx_kill_vid   = mlxsw_sp_port_kill_vid,
.ndo_get_phys_port_name = mlxsw_sp_port_get_phys_port_name,
.ndo_set_features   = mlxsw_sp_set_features,
+   .ndo_get_port_parent_id = mlxsw_sp_port_get_port_parent_id,
 };
 
 static void mlxsw_sp_port_get_drvinfo(struct net_device *dev,
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index a4a9fe992193..95e37de3e48f 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -451,11 +451,6 @@ static int mlxsw_sp_port_attr_get(struct net_device *dev,
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
 
switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = sizeof(mlxsw_sp->base_mac);
-   memcpy(&attr->u.ppid.id, &mlxsw_sp->base_mac,
-  attr->u.ppid.id_len);
-   break;
case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
mlxsw_sp_port_bridge_flags_get(mlxsw_sp->bridge, attr->orig_dev,
   &attr->u.brport_flags);
diff --git a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c 
b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
index 2d4f213e154d..3814ba8af517 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
@@ -390,6 +390,18 @@ static int mlxsw_sx_port_get_phys_port_name(struct 
net_device *dev, char *name,
  name, len);
 }
 
+static int mlxsw_sx_port_get_port_parent_id(struct net_device *dev,
+   struct netdev_phys_item_id *ppid)
+{
+   struct mlxsw_sx_port *mlxsw_sx_port = netdev_priv(dev);
+   struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx;
+
+   ppid->id_len = sizeof(mlxsw_sx->hw_id);
+   memcpy(&ppid->id, &mlxsw_sx->hw_id, ppid->id_len);
+
+   return 0;
+}
+
 static const struct net_device_ops mlxsw_sx_port_netdev_ops = {
.ndo_open   = mlxsw_sx_port_open,
.ndo_stop   = mlxsw_sx_port_stop,
@@ -397,6 +409,7 @@ static const struct net_device_ops mlxsw_sx_port_netdev_ops 
= {
.ndo_change_mtu = mlxsw_sx_port_change_mtu,
.ndo_get_stats64= mlxsw_sx_port_get_stats64,
.ndo_get_phys_port_name = mlxsw_sx_port_get_phys_port_name,
+   .ndo_get_port_parent_id = mlxsw_sx_port_get_port_parent_id,
 };
 
 static void mlxsw_sx_port_get_drvinfo(struct net_device *dev,
@@ -901,28 +914,6 @@ static const struct ethtool_ops mlxsw_sx_port_ethtool_ops 
= {
.set_link_ksettings = mlxsw_sx_port_set_link_ksettings,
 };
 
-static int mlxsw_sx_port_attr_get(struct net_device *dev,
- struct switchdev_attr *attr)
-{
-   struct mlxsw_sx_port *mlxsw_sx_port = netdev_priv(dev);
-   struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx;
-
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = sizeof(mlxsw_sx->hw_id);
-   memcpy(&attr->u.ppid.id, &mlxsw_sx->hw_id, attr->u.ppid.id_len);
-   break;
-   default:
-   return -EOPNOTSUPP;
-   }
-
-   return 0;
-}
-
-static const struct s

[PATCH net-next v2 12/12] net: Get rid of SWITCHDEV_ATTR_ID_PORT_PARENT_ID

2019-02-05 Thread Florian Fainelli
Now that we have a dedicated NDO for getting a port's parent ID, get rid
of SWITCHDEV_ATTR_ID_PORT_PARENT_ID and convert all callers to use the
NDO exclusively. This is a preliminary change to getting rid of
switchdev_ops eventually.

Signed-off-by: Florian Fainelli 
---
 include/net/switchdev.h   | 11 ---
 net/bridge/br_switchdev.c | 16 
 net/core/net-sysfs.c  | 19 ---
 net/core/rtnetlink.c  | 18 --
 net/ipv4/ipmr.c   | 16 
 net/switchdev/switchdev.c | 20 
 6 files changed, 16 insertions(+), 84 deletions(-)

diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index 63843ae5dc81..5e87b54c5dc5 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -43,7 +43,6 @@ static inline bool switchdev_trans_ph_commit(struct 
switchdev_trans *trans)
 
 enum switchdev_attr_id {
SWITCHDEV_ATTR_ID_UNDEFINED,
-   SWITCHDEV_ATTR_ID_PORT_PARENT_ID,
SWITCHDEV_ATTR_ID_PORT_STP_STATE,
SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS,
SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT,
@@ -61,7 +60,6 @@ struct switchdev_attr {
void *complete_priv;
void (*complete)(struct net_device *dev, int err, void *priv);
union {
-   struct netdev_phys_item_id ppid;/* PORT_PARENT_ID */
u8 stp_state;   /* PORT_STP_STATE */
unsigned long brport_flags; /* PORT_BRIDGE_FLAGS */
unsigned long brport_flags_support; /* 
PORT_BRIDGE_FLAGS_SUPPORT */
@@ -208,9 +206,6 @@ void switchdev_port_fwd_mark_set(struct net_device *dev,
 struct net_device *group_dev,
 bool joining);
 
-bool switchdev_port_same_parent_id(struct net_device *a,
-  struct net_device *b);
-
 int switchdev_handle_port_obj_add(struct net_device *dev,
struct switchdev_notifier_port_obj_info *port_obj_info,
bool (*check_cb)(const struct net_device *dev),
@@ -295,12 +290,6 @@ call_switchdev_blocking_notifiers(unsigned long val,
return NOTIFY_DONE;
 }
 
-static inline bool switchdev_port_same_parent_id(struct net_device *a,
-struct net_device *b)
-{
-   return false;
-}
-
 static inline int
 switchdev_handle_port_obj_add(struct net_device *dev,
struct switchdev_notifier_port_obj_info *port_obj_info,
diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
index 06b0ae44585f..c86d0f4a6aa8 100644
--- a/net/bridge/br_switchdev.c
+++ b/net/bridge/br_switchdev.c
@@ -14,8 +14,7 @@ static int br_switchdev_mark_get(struct net_bridge *br, 
struct net_device *dev)
 
/* dev is yet to be added to the port list. */
list_for_each_entry(p, &br->port_list, list) {
-   if (netdev_port_same_parent_id(dev, p->dev) ||
-   switchdev_port_same_parent_id(dev, p->dev))
+   if (netdev_port_same_parent_id(dev, p->dev))
return p->offload_fwd_mark;
}
 
@@ -24,19 +23,12 @@ static int br_switchdev_mark_get(struct net_bridge *br, 
struct net_device *dev)
 
 int nbp_switchdev_mark_set(struct net_bridge_port *p)
 {
-   const struct net_device_ops *ops = p->dev->netdev_ops;
-   struct switchdev_attr attr = {
-   .orig_dev = p->dev,
-   .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID,
-   };
-   int err;
+   struct netdev_phys_item_id ppid = { };
+   int err = -EOPNOTSUPP;
 
ASSERT_RTNL();
 
-   if (ops->ndo_get_port_parent_id)
-   err = dev_get_port_parent_id(p->dev, &attr.u.ppid, true);
-   else
-   err = switchdev_port_attr_get(p->dev, &attr);
+   err = dev_get_port_parent_id(p->dev, &ppid, true);
if (err) {
if (err == -EOPNOTSUPP)
return 0;
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 4eace9f1dcf9..7c5061123ead 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -12,7 +12,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -495,27 +494,17 @@ static ssize_t phys_switch_id_show(struct device *dev,
   struct device_attribute *attr, char *buf)
 {
struct net_device *netdev = to_net_dev(dev);
-   const struct net_device_ops *ops = netdev->netdev_ops;
ssize_t ret = -EINVAL;
 
if (!rtnl_trylock())
return restart_syscall();
 
if (dev_isalive(netdev)) {
-   struct switchdev_attr attr = {
-   .orig_dev = netdev,
-   .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID,
-   .flags = SWITCHDEV_F_NO_RECURSE,
-   };
-
-   if (ops->ndo_get_port_parent_id)
-   ret = d

[PATCH net-next v2 11/12] net: dsa: Implement ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
DSA implements SWITCHDEV_ATTR_ID_PORT_PARENT_ID and we want to get rid
of switchdev_ops eventually, ease that migration by implementing a
ndo_get_port_parent_id() function which returns what
switchdev_port_attr_get() would do.

Signed-off-by: Florian Fainelli 
---
 net/dsa/slave.c | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 91de3a663226..70395a0ae52e 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -362,18 +362,23 @@ static int dsa_slave_port_obj_del(struct net_device *dev,
return err;
 }
 
-static int dsa_slave_port_attr_get(struct net_device *dev,
-  struct switchdev_attr *attr)
+static int dsa_slave_get_port_parent_id(struct net_device *dev,
+   struct netdev_phys_item_id *ppid)
 {
struct dsa_port *dp = dsa_slave_to_port(dev);
struct dsa_switch *ds = dp->ds;
struct dsa_switch_tree *dst = ds->dst;
 
+   ppid->id_len = sizeof(dst->index);
+   memcpy(&ppid->id, &dst->index, ppid->id_len);
+
+   return 0;
+}
+
+static int dsa_slave_port_attr_get(struct net_device *dev,
+  struct switchdev_attr *attr)
+{
switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = sizeof(dst->index);
-   memcpy(&attr->u.ppid.id, &dst->index, attr->u.ppid.id_len);
-   break;
case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT:
attr->u.brport_flags_support = 0;
break;
@@ -1046,6 +1051,7 @@ static const struct net_device_ops dsa_slave_netdev_ops = 
{
.ndo_get_phys_port_name = dsa_slave_get_phys_port_name,
.ndo_setup_tc   = dsa_slave_setup_tc,
.ndo_get_stats64= dsa_slave_get_stats64,
+   .ndo_get_port_parent_id = dsa_slave_get_port_parent_id,
 };
 
 static const struct switchdev_ops dsa_slave_switchdev_ops = {
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next v2 10/12] staging: fsl-dpaa2: ethsw: Implement ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
ethsw implements SWITCHDEV_ATTR_ID_PORT_PARENT_ID and we want to get rid
of switchdev_ops eventually, ease that migration by implementing a
ndo_get_port_parent_id() function which returns what
switchdev_port_attr_get() would do.

Signed-off-by: Florian Fainelli 
---
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index daabaceeea52..622f32377b91 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -505,6 +505,17 @@ static netdev_tx_t port_dropframe(struct sk_buff *skb,
return NETDEV_TX_OK;
 }
 
+static int swdev_get_port_parent_id(struct net_device *dev,
+   struct netdev_phys_item_id *ppid)
+{
+   struct ethsw_port_priv *port_priv = netdev_priv(dev);
+
+   ppid->id_len = 1;
+   ppid->id[0] = port_priv->ethsw_data->dev_id;
+
+   return 0;
+}
+
 static const struct net_device_ops ethsw_port_ops = {
.ndo_open   = port_open,
.ndo_stop   = port_stop,
@@ -515,6 +526,7 @@ static const struct net_device_ops ethsw_port_ops = {
.ndo_get_offload_stats  = port_get_offload_stats,
 
.ndo_start_xmit = port_dropframe,
+   .ndo_get_port_parent_id = swdev_get_port_parent_id,
 };
 
 static void ethsw_links_state_update(struct ethsw_core *ethsw)
@@ -634,10 +646,6 @@ static int swdev_port_attr_get(struct net_device *netdev,
struct ethsw_port_priv *port_priv = netdev_priv(netdev);
 
switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = 1;
-   attr->u.ppid.id[0] = port_priv->ethsw_data->dev_id;
-   break;
case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
attr->u.brport_flags =
(port_priv->ethsw_data->learning ? BR_LEARNING : 0) |
@@ -1434,7 +1442,6 @@ static int ethsw_probe_port(struct ethsw_core *ethsw, u16 
port_idx)
SET_NETDEV_DEV(port_netdev, dev);
port_netdev->netdev_ops = ðsw_port_ops;
port_netdev->ethtool_ops = ðsw_port_ethtool_ops;
-   port_netdev->switchdev_ops = ðsw_port_switchdev_ops;
 
/* Set MTU limits */
port_netdev->min_mtu = ETH_MIN_MTU;
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next v2 09/12] netdevsim: Implement ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
netdevsim only supports SWITCHDEV_ATTR_ID_PORT_PARENT_ID, which makes it a
great candidate to be converted to use the ndo_get_port_parent_id() NDO
instead of implementing switchdev_port_attr_get().

Signed-off-by: Florian Fainelli 
---
 drivers/net/netdevsim/netdev.c | 22 ++
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c
index 8d8e2b3f263e..84de37478624 100644
--- a/drivers/net/netdevsim/netdev.c
+++ b/drivers/net/netdevsim/netdev.c
@@ -148,26 +148,16 @@ static struct device_type nsim_dev_type = {
.release = nsim_dev_release,
 };
 
-static int
-nsim_port_attr_get(struct net_device *dev, struct switchdev_attr *attr)
+static int nsim_get_port_parent_id(struct net_device *dev,
+  struct netdev_phys_item_id *ppid)
 {
struct netdevsim *ns = netdev_priv(dev);
 
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = sizeof(ns->sdev->switch_id);
-   memcpy(&attr->u.ppid.id, &ns->sdev->switch_id,
-  attr->u.ppid.id_len);
-   return 0;
-   default:
-   return -EOPNOTSUPP;
-   }
+   ppid->id_len = sizeof(ns->sdev->switch_id);
+   memcpy(&ppid->id, &ns->sdev->switch_id, ppid->id_len);
+   return 0;
 }
 
-static const struct switchdev_ops nsim_switchdev_ops = {
-   .switchdev_port_attr_get= nsim_port_attr_get,
-};
-
 static int nsim_init(struct net_device *dev)
 {
char sdev_ddir_name[10], sdev_link_name[32];
@@ -214,7 +204,6 @@ static int nsim_init(struct net_device *dev)
goto err_bpf_uninit;
 
SET_NETDEV_DEV(dev, &ns->dev);
-   SWITCHDEV_SET_OPS(dev, &nsim_switchdev_ops);
 
err = nsim_devlink_setup(ns);
if (err)
@@ -493,6 +482,7 @@ static const struct net_device_ops nsim_netdev_ops = {
.ndo_setup_tc   = nsim_setup_tc,
.ndo_set_features   = nsim_set_features,
.ndo_bpf= nsim_bpf,
+   .ndo_get_port_parent_id = nsim_get_port_parent_id,
 };
 
 static void nsim_setup(struct net_device *dev)
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next v2 08/12] rocker: Implement ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
mlxsw implements SWITCHDEV_ATTR_ID_PORT_PARENT_ID and we want to get rid
of switchdev_ops eventually, ease that migration by implementing a
ndo_get_port_parent_id() function which returns what
switchdev_port_attr_get() would do.

Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/rocker/rocker_main.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/rocker/rocker_main.c 
b/drivers/net/ethernet/rocker/rocker_main.c
index 62a205eba9f7..596f44dbfae1 100644
--- a/drivers/net/ethernet/rocker/rocker_main.c
+++ b/drivers/net/ethernet/rocker/rocker_main.c
@@ -2026,6 +2026,18 @@ static void rocker_port_neigh_destroy(struct net_device 
*dev,
err);
 }
 
+static int rocker_port_get_port_parent_id(struct net_device *dev,
+ struct netdev_phys_item_id *ppid)
+{
+   const struct rocker_port *rocker_port = netdev_priv(dev);
+   const struct rocker *rocker = rocker_port->rocker;
+
+   ppid->id_len = sizeof(rocker->hw.id);
+   memcpy(&ppid->id, &rocker->hw.id, ppid->id_len);
+
+   return 0;
+}
+
 static const struct net_device_ops rocker_port_netdev_ops = {
.ndo_open   = rocker_port_open,
.ndo_stop   = rocker_port_stop,
@@ -2035,6 +2047,7 @@ static const struct net_device_ops rocker_port_netdev_ops 
= {
.ndo_get_phys_port_name = rocker_port_get_phys_port_name,
.ndo_change_proto_down  = rocker_port_change_proto_down,
.ndo_neigh_destroy  = rocker_port_neigh_destroy,
+   .ndo_get_port_parent_id = rocker_port_get_port_parent_id,
 };
 
 /
@@ -2049,10 +2062,6 @@ static int rocker_port_attr_get(struct net_device *dev,
int err = 0;
 
switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = sizeof(rocker->hw.id);
-   memcpy(&attr->u.ppid.id, &rocker->hw.id, attr->u.ppid.id_len);
-   break;
case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
err = rocker_world_port_attr_bridge_flags_get(rocker_port,
  
&attr->u.brport_flags);
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next v2 07/12] nfp: Implement ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
NFP only supports SWITCHDEV_ATTR_ID_PORT_PARENT_ID, which makes it a
great candidate to be converted to use the ndo_get_port_parent_id() NDO
instead of implementing switchdev_port_attr_get().

Since NFP uses switchdev_port_same_parent_id() convert it to use
netdev_port_same_parent_id().

Signed-off-by: Florian Fainelli 
---
 .../ethernet/netronome/nfp/flower/action.c|  3 +--
 .../ethernet/netronome/nfp/nfp_net_common.c   |  4 +---
 .../net/ethernet/netronome/nfp/nfp_net_repr.c |  4 +---
 drivers/net/ethernet/netronome/nfp/nfp_port.c | 23 +--
 drivers/net/ethernet/netronome/nfp/nfp_port.h |  4 +++-
 5 files changed, 12 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/flower/action.c 
b/drivers/net/ethernet/netronome/nfp/flower/action.c
index 8d54b36afee8..7b217d7285c7 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/action.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/action.c
@@ -3,7 +3,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -137,7 +136,7 @@ nfp_fl_output(struct nfp_app *app, struct nfp_fl_output 
*output,
 
if (nfp_netdev_is_nfp_repr(in_dev)) {
/* Confirm ingress and egress are on same device. */
-   if (!switchdev_port_same_parent_id(in_dev, out_dev))
+   if (!netdev_port_same_parent_id(in_dev, out_dev))
return -EOPNOTSUPP;
}
 
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c 
b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index 7d2d4241498f..776f6c07701b 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -36,7 +36,6 @@
 #include 
 #include 
 
-#include 
 #include 
 
 #include "nfpcore/nfp_nsp.h"
@@ -3531,6 +3530,7 @@ const struct net_device_ops nfp_net_netdev_ops = {
.ndo_udp_tunnel_add = nfp_net_add_vxlan_port,
.ndo_udp_tunnel_del = nfp_net_del_vxlan_port,
.ndo_bpf= nfp_net_xdp,
+   .ndo_get_port_parent_id = nfp_port_get_port_parent_id,
 };
 
 /**
@@ -3815,8 +3815,6 @@ static void nfp_net_netdev_init(struct nfp_net *nn)
netdev->netdev_ops = &nfp_net_netdev_ops;
netdev->watchdog_timeo = msecs_to_jiffies(5 * 1000);
 
-   SWITCHDEV_SET_OPS(netdev, &nfp_port_switchdev_ops);
-
/* MTU range: 68 - hw-specific max */
netdev->min_mtu = ETH_MIN_MTU;
netdev->max_mtu = nn->max_mtu;
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c 
b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
index 69d7aebda09b..62839807e21e 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
@@ -5,7 +5,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "nfpcore/nfp_cpp.h"
 #include "nfpcore/nfp_nsp.h"
@@ -273,6 +272,7 @@ const struct net_device_ops nfp_repr_netdev_ops = {
.ndo_fix_features   = nfp_repr_fix_features,
.ndo_set_features   = nfp_port_set_features,
.ndo_set_mac_address= eth_mac_addr,
+   .ndo_get_port_parent_id = nfp_port_get_port_parent_id,
 };
 
 void
@@ -336,8 +336,6 @@ int nfp_repr_init(struct nfp_app *app, struct net_device 
*netdev,
 
netdev->max_mtu = pf_netdev->max_mtu;
 
-   SWITCHDEV_SET_OPS(netdev, &nfp_port_switchdev_ops);
-
/* Set features the lower device can support with representors */
if (repr_cap & NFP_NET_CFG_CTRL_LIVE_ADDR)
netdev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_port.c 
b/drivers/net/ethernet/netronome/nfp/nfp_port.c
index 86bc149ca231..b9aa7eb99067 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_port.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_port.c
@@ -31,34 +31,23 @@ struct nfp_port *nfp_port_from_netdev(struct net_device 
*netdev)
return NULL;
 }
 
-static int
-nfp_port_attr_get(struct net_device *netdev, struct switchdev_attr *attr)
+int nfp_port_get_port_parent_id(struct net_device *netdev,
+   struct netdev_phys_item_id *ppid)
 {
struct nfp_port *port;
+   const u8 *serial;
 
port = nfp_port_from_netdev(netdev);
if (!port)
return -EOPNOTSUPP;
 
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID: {
-   const u8 *serial;
-   /* N.B: attr->u.ppid.id is binary data */
-   attr->u.ppid.id_len = nfp_cpp_serial(port->app->cpp, &serial);
-   memcpy(&attr->u.ppid.id, serial, attr->u.ppid.id_len);
-   break;
-   }
-   default:
-   return -EOPNOTSUPP;
-   }
+   /* N.B: attr->u.ppid.id is binary data */
+   ppid->id_len = nfp_cpp_serial(port->app->cpp, &serial);
+   memcpy(&ppid->id, serial, ppid->id_len);
 
return 0;
 }
 
-const struct switchdev_ops nfp_port_swit

[PATCH net-next v2 03/12] liquidio: Implement ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
Liquidio only supports SWITCHDEV_ATTR_ID_PORT_PARENT_ID, which makes it
a great candidate to be converted to use the ndo_get_port_parent_id()
NDO instead of implementing switchdev_port_attr_get().

Signed-off-by: Florian Fainelli 
---
 .../net/ethernet/cavium/liquidio/lio_main.c   | 22 
 .../net/ethernet/cavium/liquidio/lio_vf_rep.c | 25 ++-
 2 files changed, 12 insertions(+), 35 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 3d24133e5e49..e97e6754ee09 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -21,7 +21,6 @@
 #include 
 #include 
 #include 
-#include 
 #include "liquidio_common.h"
 #include "octeon_droq.h"
 #include "octeon_iq.h"
@@ -3184,7 +3183,8 @@ static const struct devlink_ops liquidio_devlink_ops = {
 };
 
 static int
-lio_pf_switchdev_attr_get(struct net_device *dev, struct switchdev_attr *attr)
+liquidio_get_port_parent_id(struct net_device *dev,
+   struct netdev_phys_item_id *ppid)
 {
struct lio *lio = GET_LIO(dev);
struct octeon_device *oct = lio->oct_dev;
@@ -3192,24 +3192,12 @@ lio_pf_switchdev_attr_get(struct net_device *dev, 
struct switchdev_attr *attr)
if (oct->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV)
return -EOPNOTSUPP;
 
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = ETH_ALEN;
-   ether_addr_copy(attr->u.ppid.id,
-   (void *)&lio->linfo.hw_addr + 2);
-   break;
-
-   default:
-   return -EOPNOTSUPP;
-   }
+   ppid->id_len = ETH_ALEN;
+   ether_addr_copy(ppid->id, (void *)&lio->linfo.hw_addr + 2);
 
return 0;
 }
 
-static const struct switchdev_ops lio_pf_switchdev_ops = {
-   .switchdev_port_attr_get = lio_pf_switchdev_attr_get,
-};
-
 static int liquidio_get_vf_stats(struct net_device *netdev, int vfidx,
 struct ifla_vf_stats *vf_stats)
 {
@@ -3259,6 +3247,7 @@ static const struct net_device_ops lionetdevops = {
.ndo_set_vf_trust   = liquidio_set_vf_trust,
.ndo_set_vf_link_state  = liquidio_set_vf_link_state,
.ndo_get_vf_stats   = liquidio_get_vf_stats,
+   .ndo_get_port_parent_id = liquidio_get_port_parent_id,
 };
 
 /** \brief Entry point for the liquidio module
@@ -3534,7 +3523,6 @@ static int setup_nic_devices(struct octeon_device 
*octeon_dev)
 * netdev tasks.
 */
netdev->netdev_ops = &lionetdevops;
-   SWITCHDEV_SET_OPS(netdev, &lio_pf_switchdev_ops);
 
retval = netif_set_real_num_rx_queues(netdev, num_oqueues);
if (retval) {
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c 
b/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c
index de61060721c4..f3f2e71431ac 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c
@@ -25,7 +25,6 @@
 #include "octeon_nic.h"
 #include "octeon_main.h"
 #include "octeon_network.h"
-#include 
 #include "lio_vf_rep.h"
 
 static int lio_vf_rep_open(struct net_device *ndev);
@@ -38,6 +37,8 @@ static int lio_vf_rep_phys_port_name(struct net_device *dev,
 static void lio_vf_rep_get_stats64(struct net_device *dev,
   struct rtnl_link_stats64 *stats64);
 static int lio_vf_rep_change_mtu(struct net_device *ndev, int new_mtu);
+static int lio_vf_get_port_parent_id(struct net_device *dev,
+struct netdev_phys_item_id *ppid);
 
 static const struct net_device_ops lio_vf_rep_ndev_ops = {
.ndo_open = lio_vf_rep_open,
@@ -47,6 +48,7 @@ static const struct net_device_ops lio_vf_rep_ndev_ops = {
.ndo_get_phys_port_name = lio_vf_rep_phys_port_name,
.ndo_get_stats64 = lio_vf_rep_get_stats64,
.ndo_change_mtu = lio_vf_rep_change_mtu,
+   .ndo_get_port_parent_id = lio_vf_get_port_parent_id,
 };
 
 static int
@@ -443,31 +445,19 @@ lio_vf_rep_pkt_xmit(struct sk_buff *skb, struct 
net_device *ndev)
return NETDEV_TX_OK;
 }
 
-static int
-lio_vf_rep_attr_get(struct net_device *dev, struct switchdev_attr *attr)
+static int lio_vf_get_port_parent_id(struct net_device *dev,
+struct netdev_phys_item_id *ppid)
 {
struct lio_vf_rep_desc *vf_rep = netdev_priv(dev);
struct net_device *parent_ndev = vf_rep->parent_ndev;
struct lio *lio = GET_LIO(parent_ndev);
 
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = ETH_ALEN;
-   ether_addr_copy(attr->u.ppid.id,
-   (void *)&lio->linfo.hw_addr + 2);
-   break;
-
-   default:
-   return -EOPNOTSUPP;
-

[PATCH net-next v2 00/12] net: Introduce ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
Hi all,

Based on discussion with Ido and feedback from Jakub there are clearly
two classes of users that implement SWITCHDEV_ATTR_ID_PORT_PARENT_ID:

- PF/VF drivers which typically only implement return the port's parent
  ID, yet have to implement switchdev_port_attr_get() just for that

- Ethernet switch drivers: mlxsw, ocelot, DSA, etc. which implement more
  attributes which we want to be able to eventually veto in the context
  of the caller, thus making them candidates for using a blocking notifier
  chain

Changes in v2:

- resolved build failures spotted by kbuild test robot
- added helpers functions into the core network device layer:
  dev_get_port_parent_id() and netdev_port_same_parent_id();
- added support for recursion to lower devices

Changes from RFC:

- introduce a ndo_get_port_parent_id() and convert all relevant drivers
  to use it

- get rid of SWITCHDEV_ATTR_ID_PORT_PARENT_ID

A subsequent set of patches will convert switchdev_port_attr_set() to
use a blocking notifier call, and still get rid of
switchdev_port_attr_get() altogether.

Florian Fainelli (12):
  net: Introduce ndo_get_port_parent_id()
  bnxt: Implement ndo_get_port_parent_id()
  liquidio: Implement ndo_get_port_parent_id()
  net/mlx5e: Implement ndo_get_port_parent_id()
  mlxsw: Implement ndo_get_port_parent_id()
  mscc: ocelot: Implement ndo_get_port_parent_id()
  nfp: Implement ndo_get_port_parent_id()
  rocker: Implement ndo_get_port_parent_id()
  netdevsim: Implement ndo_get_port_parent_id()
  staging: fsl-dpaa2: ethsw: Implement ndo_get_port_parent_id()
  net: dsa: Implement ndo_get_port_parent_id()
  net: Get rid of SWITCHDEV_ATTR_ID_PORT_PARENT_ID

 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 28 +++--
 drivers/net/ethernet/broadcom/bnxt/bnxt.h |  4 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c  |  3 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | 12 ++--
 .../net/ethernet/cavium/liquidio/lio_main.c   | 22 ++-
 .../net/ethernet/cavium/liquidio/lio_vf_rep.c | 25 +++-
 .../ethernet/mellanox/mlx5/core/en/tc_tun.c   |  2 +-
 .../net/ethernet/mellanox/mlx5/core/en_rep.c  | 31 --
 .../net/ethernet/mellanox/mlx5/core/en_tc.c   |  5 +-
 .../net/ethernet/mellanox/mlxsw/spectrum.c| 13 +
 .../mellanox/mlxsw/spectrum_switchdev.c   |  5 --
 .../net/ethernet/mellanox/mlxsw/switchx2.c| 36 +---
 drivers/net/ethernet/mscc/ocelot.c| 33 +--
 .../ethernet/netronome/nfp/flower/action.c|  3 +-
 .../ethernet/netronome/nfp/nfp_net_common.c   |  4 +-
 .../net/ethernet/netronome/nfp/nfp_net_repr.c |  4 +-
 drivers/net/ethernet/netronome/nfp/nfp_port.c | 23 ++--
 drivers/net/ethernet/netronome/nfp/nfp_port.h |  4 +-
 drivers/net/ethernet/rocker/rocker_main.c | 17 --
 drivers/net/netdevsim/netdev.c| 22 ++-
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c   | 17 --
 include/linux/netdevice.h |  9 +++
 include/net/switchdev.h   | 11 
 net/bridge/br_switchdev.c | 11 ++--
 net/core/dev.c| 57 +++
 net/core/net-sysfs.c  | 12 +---
 net/core/rtnetlink.c  | 14 ++---
 net/dsa/slave.c   | 18 --
 net/ipv4/ipmr.c   | 14 ++---
 net/switchdev/switchdev.c | 20 ---
 30 files changed, 219 insertions(+), 260 deletions(-)

-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next v2 04/12] net/mlx5e: Implement ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
mlx5e only supports SWITCHDEV_ATTR_ID_PORT_PARENT_ID, which makes it a
great candidate to be converted to use the ndo_get_port_parent_id() NDO
instead of implementing switchdev_port_attr_get().

Since mlx5e makes use of switchdev_port_parent_id() convert it to use
netdev_port_same_parent_id().

Signed-off-by: Florian Fainelli 
---
 .../ethernet/mellanox/mlx5/core/en/tc_tun.c   |  2 +-
 .../net/ethernet/mellanox/mlx5/core/en_rep.c  | 31 +++
 .../net/ethernet/mellanox/mlx5/core/en_tc.c   |  5 ++-
 3 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
index 046948ead152..19dc4a963b90 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
@@ -25,7 +25,7 @@ static int get_route_and_out_devs(struct mlx5e_priv *priv,
/* if the egress device isn't on the same HW e-switch or
 * it's a LAG device, use the uplink
 */
-   if (!switchdev_port_same_parent_id(priv->netdev, dev) ||
+   if (!netdev_port_same_parent_id(priv->netdev, dev) ||
dst_is_lag_dev) {
*route_dev = uplink_dev;
*out_dev = *route_dev;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 5d2e0c2f6624..0b1988b330f3 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -381,7 +381,8 @@ static const struct ethtool_ops 
mlx5e_uplink_rep_ethtool_ops = {
.set_pauseparam= mlx5e_uplink_rep_set_pauseparam,
 };
 
-static int mlx5e_attr_get(struct net_device *dev, struct switchdev_attr *attr)
+static int mlx5e_rep_get_port_parent_id(struct net_device *dev,
+   struct netdev_phys_item_id *ppid)
 {
struct mlx5e_priv *priv = netdev_priv(dev);
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
@@ -398,20 +399,14 @@ static int mlx5e_attr_get(struct net_device *dev, struct 
switchdev_attr *attr)
uplink_priv = netdev_priv(uplink_dev);
}
 
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = ETH_ALEN;
-   if (uplink_upper && mlx5_lag_is_sriov(uplink_priv->mdev)) {
-   ether_addr_copy(attr->u.ppid.id, 
uplink_upper->dev_addr);
-   } else {
-   struct mlx5e_rep_priv *rpriv = priv->ppriv;
-   struct mlx5_eswitch_rep *rep = rpriv->rep;
+   ppid->id_len = ETH_ALEN;
+   if (uplink_upper && mlx5_lag_is_sriov(uplink_priv->mdev)) {
+   ether_addr_copy(ppid->id, uplink_upper->dev_addr);
+   } else {
+   struct mlx5e_rep_priv *rpriv = priv->ppriv;
+   struct mlx5_eswitch_rep *rep = rpriv->rep;
 
-   ether_addr_copy(attr->u.ppid.id, rep->hw_id);
-   }
-   break;
-   default:
-   return -EOPNOTSUPP;
+   ether_addr_copy(ppid->id, rep->hw_id);
}
 
return 0;
@@ -1284,10 +1279,6 @@ static int mlx5e_uplink_rep_set_vf_vlan(struct 
net_device *dev, int vf, u16 vlan
return 0;
 }
 
-static const struct switchdev_ops mlx5e_rep_switchdev_ops = {
-   .switchdev_port_attr_get= mlx5e_attr_get,
-};
-
 static const struct net_device_ops mlx5e_netdev_ops_vf_rep = {
.ndo_open= mlx5e_vf_rep_open,
.ndo_stop= mlx5e_vf_rep_close,
@@ -1298,6 +1289,7 @@ static const struct net_device_ops 
mlx5e_netdev_ops_vf_rep = {
.ndo_has_offload_stats   = mlx5e_rep_has_offload_stats,
.ndo_get_offload_stats   = mlx5e_rep_get_offload_stats,
.ndo_change_mtu  = mlx5e_vf_rep_change_mtu,
+   .ndo_get_port_parent_id  = mlx5e_rep_get_port_parent_id,
 };
 
 static const struct net_device_ops mlx5e_netdev_ops_uplink_rep = {
@@ -1319,6 +1311,7 @@ static const struct net_device_ops 
mlx5e_netdev_ops_uplink_rep = {
.ndo_get_vf_config   = mlx5e_get_vf_config,
.ndo_get_vf_stats= mlx5e_get_vf_stats,
.ndo_set_vf_vlan = mlx5e_uplink_rep_set_vf_vlan,
+   .ndo_get_port_parent_id  = mlx5e_rep_get_port_parent_id,
 };
 
 bool mlx5e_eswitch_rep(struct net_device *netdev)
@@ -1393,8 +1386,6 @@ static void mlx5e_build_rep_netdev(struct net_device 
*netdev)
netdev->watchdog_timeo= 15 * HZ;
 
 
-   netdev->switchdev_ops = &mlx5e_rep_switchdev_ops;
-
netdev->features |= NETIF_F_HW_TC | NETIF_F_NETNS_LOCAL;
netdev->hw_features  |= NETIF_F_HW_TC;
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 74159d39dd66..098b28feba0c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/cor

[PATCH net-next v2 06/12] mscc: ocelot: Implement ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
Ocelot only supports SWITCHDEV_ATTR_ID_PORT_PARENT_ID as a valid
switchdev attribute getter, convert it to use ndo_get_port_parent_id()
and get rid of the switchdev_ops::switchdev_port_attr_get altogether.

Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/mscc/ocelot.c | 33 --
 1 file changed, 13 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot.c 
b/drivers/net/ethernet/mscc/ocelot.c
index c6a575eb0ff5..195306d05bcd 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -916,6 +916,18 @@ static int ocelot_set_features(struct net_device *dev,
return 0;
 }
 
+static int ocelot_get_port_parent_id(struct net_device *dev,
+struct netdev_phys_item_id *ppid)
+{
+   struct ocelot_port *ocelot_port = netdev_priv(dev);
+   struct ocelot *ocelot = ocelot_port->ocelot;
+
+   ppid->id_len = sizeof(ocelot->base_mac);
+   memcpy(&ppid->id, &ocelot->base_mac, ppid->id_len);
+
+   return 0;
+}
+
 static const struct net_device_ops ocelot_port_netdev_ops = {
.ndo_open   = ocelot_port_open,
.ndo_stop   = ocelot_port_stop,
@@ -930,6 +942,7 @@ static const struct net_device_ops ocelot_port_netdev_ops = 
{
.ndo_vlan_rx_add_vid= ocelot_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid   = ocelot_vlan_rx_kill_vid,
.ndo_set_features   = ocelot_set_features,
+   .ndo_get_port_parent_id = ocelot_get_port_parent_id,
 };
 
 static void ocelot_get_strings(struct net_device *netdev, u32 sset, u8 *data)
@@ -1013,25 +1026,6 @@ static const struct ethtool_ops ocelot_ethtool_ops = {
.set_link_ksettings = phy_ethtool_set_link_ksettings,
 };
 
-static int ocelot_port_attr_get(struct net_device *dev,
-   struct switchdev_attr *attr)
-{
-   struct ocelot_port *ocelot_port = netdev_priv(dev);
-   struct ocelot *ocelot = ocelot_port->ocelot;
-
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = sizeof(ocelot->base_mac);
-   memcpy(&attr->u.ppid.id, &ocelot->base_mac,
-  attr->u.ppid.id_len);
-   break;
-   default:
-   return -EOPNOTSUPP;
-   }
-
-   return 0;
-}
-
 static int ocelot_port_attr_stp_state_set(struct ocelot_port *ocelot_port,
  struct switchdev_trans *trans,
  u8 state)
@@ -1331,7 +1325,6 @@ static int ocelot_port_obj_del(struct net_device *dev,
 }
 
 static const struct switchdev_ops ocelot_port_switchdev_ops = {
-   .switchdev_port_attr_get= ocelot_port_attr_get,
.switchdev_port_attr_set= ocelot_port_attr_set,
 };
 
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next v2 01/12] net: Introduce ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
In preparation for getting rid of switchdev_ops, create a dedicated NDO
operation for getting the port's parent identifier. There are
essentially two classes of drivers that need to implement getting the
port's parent ID which are VF/PF drivers with a built-in switch, and
pure switchdev drivers such as mlxsw, ocelot, dsa etc.

We introduce a helper function: dev_get_port_parent_id() which supports
recursing into the lower devices to obtain the first port's parent ID.

Convert the bridge, core and ipv4 multicast routing code to check for
such ndo_get_port_parent_id() and call the helper functino when valid
before falling back to switchdev_port_attr_get(). This will allow us to
convert all relevant drivers in one go instead of having to implement
both switchdev_port_attr_get() and ndo_get_port_parent_id() operations,
then get rid of switchdev_port_attr_get().

Signed-off-by: Florian Fainelli 
---
 include/linux/netdevice.h |  9 +++
 net/bridge/br_switchdev.c |  9 +--
 net/core/dev.c| 57 +++
 net/core/net-sysfs.c  |  7 -
 net/core/rtnetlink.c  |  6 -
 net/ipv4/ipmr.c   |  8 +-
 6 files changed, 91 insertions(+), 5 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index ba57d0ba425e..1d95e634f3fe 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1188,6 +1188,10 @@ struct dev_ifalias {
  * not implement this, it is assumed that the hw is not able to have
  * multiple net devices on single physical port.
  *
+ * int (*ndo_get_port_parent_id)(struct net_device *dev,
+ *  struct netdev_phys_item_id *ppid)
+ * Called to get the parent ID of the physical port of this device.
+ *
  * void (*ndo_udp_tunnel_add)(struct net_device *dev,
  *   struct udp_tunnel_info *ti);
  * Called by UDP tunnel to notify a driver about the UDP port and socket
@@ -1412,6 +1416,8 @@ struct net_device_ops {
  bool new_carrier);
int (*ndo_get_phys_port_id)(struct net_device *dev,
struct 
netdev_phys_item_id *ppid);
+   int (*ndo_get_port_parent_id)(struct net_device 
*dev,
+ struct 
netdev_phys_item_id *ppid);
int (*ndo_get_phys_port_name)(struct net_device 
*dev,
  char *name, size_t 
len);
void(*ndo_udp_tunnel_add)(struct net_device *dev,
@@ -3651,6 +3657,9 @@ int dev_get_phys_port_id(struct net_device *dev,
 struct netdev_phys_item_id *ppid);
 int dev_get_phys_port_name(struct net_device *dev,
   char *name, size_t len);
+int dev_get_port_parent_id(struct net_device *dev,
+  struct netdev_phys_item_id *ppid, bool recurse);
+bool netdev_port_same_parent_id(struct net_device *a, struct net_device *b);
 int dev_change_proto_down(struct net_device *dev, bool proto_down);
 struct sk_buff *validate_xmit_skb_list(struct sk_buff *skb, struct net_device 
*dev, bool *again);
 struct sk_buff *dev_hard_start_xmit(struct sk_buff *skb, struct net_device 
*dev,
diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
index 4d2b9eb7604a..06b0ae44585f 100644
--- a/net/bridge/br_switchdev.c
+++ b/net/bridge/br_switchdev.c
@@ -14,7 +14,8 @@ static int br_switchdev_mark_get(struct net_bridge *br, 
struct net_device *dev)
 
/* dev is yet to be added to the port list. */
list_for_each_entry(p, &br->port_list, list) {
-   if (switchdev_port_same_parent_id(dev, p->dev))
+   if (netdev_port_same_parent_id(dev, p->dev) ||
+   switchdev_port_same_parent_id(dev, p->dev))
return p->offload_fwd_mark;
}
 
@@ -23,6 +24,7 @@ static int br_switchdev_mark_get(struct net_bridge *br, 
struct net_device *dev)
 
 int nbp_switchdev_mark_set(struct net_bridge_port *p)
 {
+   const struct net_device_ops *ops = p->dev->netdev_ops;
struct switchdev_attr attr = {
.orig_dev = p->dev,
.id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID,
@@ -31,7 +33,10 @@ int nbp_switchdev_mark_set(struct net_bridge_port *p)
 
ASSERT_RTNL();
 
-   err = switchdev_port_attr_get(p->dev, &attr);
+   if (ops->ndo_get_port_parent_id)
+   err = dev_get_port_parent_id(p->dev, &attr.u.ppid, true);
+   else
+   err = switchdev_port_attr_get(p->dev, &attr);
if (err) {
if (err == -EOPNOTSUPP)
return 0;
diff --git a/net/core/dev.c b/net/core/dev.c
index bfa4be42afff..8c6d5cf8a308 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -7877,6 +7877,63 @@ int dev_get_phys_port_name(struct net_device *de

[PATCH net-next v2 02/12] bnxt: Implement ndo_get_port_parent_id()

2019-02-05 Thread Florian Fainelli
BNXT only supports SWITCHDEV_ATTR_ID_PORT_PARENT_ID, which makes it a
great candidate to be converted to use the ndo_get_port_parent_id() NDO
instead of implementing switchdev_port_attr_get(). The conversion is
straight forward here since the PF and VF code use the same getter.

Since bnxt makes uses of switchdev_port_same_parent_id() convert it to
use netdev_port_same_parent_id().

Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 28 ++-
 drivers/net/ethernet/broadcom/bnxt/bnxt.h |  4 +--
 drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c  |  3 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | 12 +++-
 4 files changed, 16 insertions(+), 31 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 6a512871176b..1c2987c3d708 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -9981,8 +9981,11 @@ static int bnxt_get_phys_port_name(struct net_device 
*dev, char *buf,
return 0;
 }
 
-int bnxt_port_attr_get(struct bnxt *bp, struct switchdev_attr *attr)
+int bnxt_get_port_parent_id(struct net_device *dev,
+   struct netdev_phys_item_id *ppid)
 {
+   struct bnxt *bp = netdev_priv(dev);
+
if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV)
return -EOPNOTSUPP;
 
@@ -9990,27 +9993,12 @@ int bnxt_port_attr_get(struct bnxt *bp, struct 
switchdev_attr *attr)
if (!BNXT_PF(bp))
return -EOPNOTSUPP;
 
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-   attr->u.ppid.id_len = sizeof(bp->switch_id);
-   memcpy(attr->u.ppid.id, bp->switch_id, attr->u.ppid.id_len);
-   break;
-   default:
-   return -EOPNOTSUPP;
-   }
-   return 0;
-}
+   ppid->id_len = sizeof(bp->switch_id);
+   memcpy(ppid->id, bp->switch_id, ppid->id_len);
 
-static int bnxt_swdev_port_attr_get(struct net_device *dev,
-   struct switchdev_attr *attr)
-{
-   return bnxt_port_attr_get(netdev_priv(dev), attr);
+   return 0;
 }
 
-static const struct switchdev_ops bnxt_switchdev_ops = {
-   .switchdev_port_attr_get= bnxt_swdev_port_attr_get
-};
-
 static const struct net_device_ops bnxt_netdev_ops = {
.ndo_open   = bnxt_open,
.ndo_start_xmit = bnxt_start_xmit,
@@ -10042,6 +10030,7 @@ static const struct net_device_ops bnxt_netdev_ops = {
.ndo_bpf= bnxt_xdp,
.ndo_bridge_getlink = bnxt_bridge_getlink,
.ndo_bridge_setlink = bnxt_bridge_setlink,
+   .ndo_get_port_parent_id = bnxt_get_port_parent_id,
.ndo_get_phys_port_name = bnxt_get_phys_port_name
 };
 
@@ -10400,7 +10389,6 @@ static int bnxt_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
dev->netdev_ops = &bnxt_netdev_ops;
dev->watchdog_timeo = BNXT_TX_TIMEOUT;
dev->ethtool_ops = &bnxt_ethtool_ops;
-   SWITCHDEV_SET_OPS(dev, &bnxt_switchdev_ops);
pci_set_drvdata(pdev, dev);
 
rc = bnxt_alloc_hwrm_resources(bp);
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h 
b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 5c886a700bcc..17554d4be651 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -22,7 +22,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -1795,7 +1794,8 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, 
bool sh, int tcs,
 int bnxt_setup_mq_tc(struct net_device *dev, u8 tc);
 int bnxt_get_max_rings(struct bnxt *, int *, int *, bool);
 int bnxt_restore_pf_fw_resources(struct bnxt *bp);
-int bnxt_port_attr_get(struct bnxt *bp, struct switchdev_attr *attr);
+int bnxt_get_port_parent_id(struct net_device *dev,
+   struct netdev_phys_item_id *ppid);
 void bnxt_dim_work(struct work_struct *work);
 int bnxt_hwrm_set_ring_coal(struct bnxt *bp, struct bnxt_napi *bnapi);
 
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
index c683b5e96b1d..170d2fbbb91b 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -45,7 +46,7 @@ static u16 bnxt_flow_get_dst_fid(struct bnxt *pf_bp, struct 
net_device *dev)
struct bnxt *bp;
 
/* check if dev belongs to the same switch */
-   if (!switchdev_port_same_parent_id(pf_bp->dev, dev)) {
+   if (!netdev_port_same_parent_id(pf_bp->dev, dev)) {
netdev_info(pf_bp->dev, "dev(ifindex=%d) not on same switch",
dev->ifindex);
return BNXT_FID_INVALID;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c 
b/drivers/net/ethernet/bro

Re: [PATCH 3/3] staging: rtl8192e: rename members of struct rtllib_device - style

2019-02-05 Thread Himadri Pandya



On 05/02/19 11:52 PM, Greg KH wrote:

On Tue, Feb 05, 2019 at 07:22:11PM +0100, Greg KH wrote:

On Tue, Feb 05, 2019 at 09:42:39AM -0800, Himadri Pandya wrote:

Rename following members of struct rtllib_device to fix checkpatch
warning: Avoid CamelCase

pDot11dInfo -> dot11d_info
 bGlobalDomain -> global_domain
 IbssStartChnl -> ibss_start_chnl

Why the use of tabs on the first line and not on the others?

Anyway, same comment here, "ibss_start_channel"?

Oops, no, it should be "bss_start_channel", no need for the initial "i",
that was left over from the horrid notation style.


Noted. Renaming it to "bss_start_channel" in V2. Thank you.

- Himadri

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/3] staging: rtl8192e: rename members of struct rt_dot11d_info - style

2019-02-05 Thread Himadri Pandya



On 05/02/19 11:53 PM, Greg KH wrote:

On Tue, Feb 05, 2019 at 09:42:38AM -0800, Himadri Pandya wrote:

Rename following members of struct rt_dot11d_info to avoid checkpatch
warning: Avoid CamelCase

bEnabled -> enabled
 CountryIelen -> country_len
 CountryIeBuf -> country_buffer
 CountryIeSrcAddr -> country_src_addr
 CountryIeWatchdog -> country_watchdog
 MaxTxPwrDbmList -> mac_tx_power_list

"max_tx_power_list"?


Yes. My bad. Apologies. Fixing it in V2.

- Himadri

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/3] staging: rtl8192e: rename members of struct chnl_txpow_triple - style

2019-02-05 Thread Himadri Pandya



On 05/02/19 11:51 PM, Greg KH wrote:

On Tue, Feb 05, 2019 at 09:42:37AM -0800, Himadri Pandya wrote:

Rename following members of struct chnl_txpow_triple to avoid
checkpatch warning: Avoid CamelCase

FirstChnl -> first_chnl
NumChnls -> num_chnls

We do have vowels, how about "first_channel" and "num_channels"?  Much
easier to read and understand, especially for non-native-english
speakers, right?


Yeah. Such names would make more sense. Doing it in V2. Thank you.

- Himadri

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: vt6656: Use the correct style for SPDX license Identifier

2019-02-05 Thread Joe Perches
On Tue, 2019-02-05 at 19:44 +0100, Greg Kroah-Hartman wrote:
> On Tue, Feb 05, 2019 at 08:36:24PM +0530, Nishad Kamdar wrote:
> > This patch corrects the style for SPDX license Identifier in mac.h
> > by using "/* */" in place of "//" as per Linux kernel licensing rules.
> > Issue found by checkpatch.
> > 
> > Signed-off-by: Nishad Kamdar 
> > ---
> >  drivers/staging/vt6656/mac.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/staging/vt6656/mac.h b/drivers/staging/vt6656/mac.h
> > index 94e700fcd0b6..75166020f7c6 100644
> > --- a/drivers/staging/vt6656/mac.h
> > +++ b/drivers/staging/vt6656/mac.h
> > @@ -1,5 +1,5 @@
> > -// SPDX-License-Identifier: GPL-2.0+
> > -/*
> > +/* SPDX-License-Identifier: GPL-2.0+
> 
> Should really be:
> 
> /* SPDX-License-Identifier: GPL-2.0+ */

There's a fair number of style inconsistencies in the kernel
sources for that already.

~8% of the .h files that have an 'SPDX-License-Identifier:'
don't use the recommended style.

$ git grep -h "SPDX-License" -- '*.h' | \
  perl -p -e 's@Identifier:.*\*/*@Identifier: ... */@; s@Identifier: 
[^\.].*@Identifier:@' | \
  sort | uniq -c | sort -rn
   8506 /* SPDX-License-Identifier: ... */
593 // SPDX-License-Identifier:
154 /* SPDX-License-Identifier:
 53  * SPDX-License-Identifier:
  1  * SPDX-License-Identifier: GPL-2.0
  1 //SPDX-License-Identifier:
  1 /*  SPDX-License-Identifier: ... */


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: vt6656: Use the correct style for SPDX license Identifier

2019-02-05 Thread Greg Kroah-Hartman
On Tue, Feb 05, 2019 at 08:36:24PM +0530, Nishad Kamdar wrote:
> This patch corrects the style for SPDX license Identifier in mac.h
> by using "/* */" in place of "//" as per Linux kernel licensing rules.
> Issue found by checkpatch.
> 
> Signed-off-by: Nishad Kamdar 
> ---
>  drivers/staging/vt6656/mac.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/vt6656/mac.h b/drivers/staging/vt6656/mac.h
> index 94e700fcd0b6..75166020f7c6 100644
> --- a/drivers/staging/vt6656/mac.h
> +++ b/drivers/staging/vt6656/mac.h
> @@ -1,5 +1,5 @@
> -// SPDX-License-Identifier: GPL-2.0+
> -/*
> +/* SPDX-License-Identifier: GPL-2.0+

Should really be:

/* SPDX-License-Identifier: GPL-2.0+ */

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/3] staging: rtl8192e: rename members of struct rt_dot11d_info - style

2019-02-05 Thread Greg KH
On Tue, Feb 05, 2019 at 09:42:38AM -0800, Himadri Pandya wrote:
> Rename following members of struct rt_dot11d_info to avoid checkpatch
> warning: Avoid CamelCase
> 
>   bEnabled -> enabled
> CountryIelen -> country_len
> CountryIeBuf -> country_buffer
> CountryIeSrcAddr -> country_src_addr
> CountryIeWatchdog -> country_watchdog
> MaxTxPwrDbmList -> mac_tx_power_list

"max_tx_power_list"?
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/3] staging: rtl8192e: rename members of struct rtllib_device - style

2019-02-05 Thread Greg KH
On Tue, Feb 05, 2019 at 07:22:11PM +0100, Greg KH wrote:
> On Tue, Feb 05, 2019 at 09:42:39AM -0800, Himadri Pandya wrote:
> > Rename following members of struct rtllib_device to fix checkpatch
> > warning: Avoid CamelCase
> > 
> > pDot11dInfo -> dot11d_info
> > bGlobalDomain -> global_domain
> > IbssStartChnl -> ibss_start_chnl
> 
> Why the use of tabs on the first line and not on the others?
> 
> Anyway, same comment here, "ibss_start_channel"?

Oops, no, it should be "bss_start_channel", no need for the initial "i",
that was left over from the horrid notation style.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/3] staging: rtl8192e: rename members of struct rtllib_device - style

2019-02-05 Thread Greg KH
On Tue, Feb 05, 2019 at 09:42:39AM -0800, Himadri Pandya wrote:
> Rename following members of struct rtllib_device to fix checkpatch
> warning: Avoid CamelCase
> 
>   pDot11dInfo -> dot11d_info
> bGlobalDomain -> global_domain
> IbssStartChnl -> ibss_start_chnl

Why the use of tabs on the first line and not on the others?

Anyway, same comment here, "ibss_start_channel"?

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/3] staging: rtl8192e: rename members of struct chnl_txpow_triple - style

2019-02-05 Thread Greg KH
On Tue, Feb 05, 2019 at 09:42:37AM -0800, Himadri Pandya wrote:
> Rename following members of struct chnl_txpow_triple to avoid
> checkpatch warning: Avoid CamelCase
> 
>   FirstChnl -> first_chnl
>   NumChnls -> num_chnls

We do have vowels, how about "first_channel" and "num_channels"?  Much
easier to read and understand, especially for non-native-english
speakers, right?

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/3] staging: rtl8192e: rename members of struct rt_dot11d_info - style

2019-02-05 Thread Himadri Pandya
Rename following members of struct rt_dot11d_info to avoid checkpatch
warning: Avoid CamelCase

bEnabled -> enabled
CountryIelen -> country_len
CountryIeBuf -> country_buffer
CountryIeSrcAddr -> country_src_addr
CountryIeWatchdog -> country_watchdog
MaxTxPwrDbmList -> mac_tx_power_list
State -> state

Signed-off-by: Himadri Pandya 
---
 drivers/staging/rtl8192e/dot11d.c | 28 ++--
 drivers/staging/rtl8192e/dot11d.h | 30 +++---
 2 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/rtl8192e/dot11d.c 
b/drivers/staging/rtl8192e/dot11d.c
index 711e8264183e..7e489f0f3c41 100644
--- a/drivers/staging/rtl8192e/dot11d.c
+++ b/drivers/staging/rtl8192e/dot11d.c
@@ -46,12 +46,12 @@ void dot11d_init(struct rtllib_device *ieee)
 {
struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(ieee);
 
-   pDot11dInfo->bEnabled = false;
+   pDot11dInfo->enabled = false;
 
-   pDot11dInfo->State = DOT11D_STATE_NONE;
-   pDot11dInfo->CountryIeLen = 0;
+   pDot11dInfo->state = DOT11D_STATE_NONE;
+   pDot11dInfo->country_len = 0;
memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER + 1);
-   memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER + 1);
+   memset(pDot11dInfo->max_tx_power_list, 0xFF, MAX_CHANNEL_NUMBER + 1);
RESET_CIE_WATCHDOG(ieee);
 }
 EXPORT_SYMBOL(dot11d_init);
@@ -104,13 +104,13 @@ void Dot11d_Reset(struct rtllib_device *ieee)
u32 i;
 
memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER + 1);
-   memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER + 1);
+   memset(pDot11dInfo->max_tx_power_list, 0xFF, MAX_CHANNEL_NUMBER + 1);
for (i = 1; i <= 11; i++)
(pDot11dInfo->channel_map)[i] = 1;
for (i = 12; i <= 14; i++)
(pDot11dInfo->channel_map)[i] = 2;
-   pDot11dInfo->State = DOT11D_STATE_NONE;
-   pDot11dInfo->CountryIeLen = 0;
+   pDot11dInfo->state = DOT11D_STATE_NONE;
+   pDot11dInfo->country_len = 0;
RESET_CIE_WATCHDOG(ieee);
 }
 
@@ -122,7 +122,7 @@ void Dot11d_UpdateCountryIe(struct rtllib_device *dev, u8 
*pTaddr,
struct chnl_txpow_triple *pTriple;
 
memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER + 1);
-   memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER + 1);
+   memset(pDot11dInfo->max_tx_power_list, 0xFF, MAX_CHANNEL_NUMBER + 1);
MaxChnlNum = 0;
NumTriples = (CoutryIeLen - 3) / 3;
pTriple = (struct chnl_txpow_triple *)(pCoutryIe + 3);
@@ -143,7 +143,7 @@ void Dot11d_UpdateCountryIe(struct rtllib_device *dev, u8 
*pTaddr,
 
for (j = 0; j < pTriple->num_chnls; j++) {
pDot11dInfo->channel_map[pTriple->first_chnl + j] = 1;
-   pDot11dInfo->MaxTxPwrDbmList[pTriple->first_chnl + j] =
+   pDot11dInfo->max_tx_power_list[pTriple->first_chnl + j] 
=
 pTriple->max_tx_power;
MaxChnlNum = pTriple->first_chnl + j;
}
@@ -153,18 +153,18 @@ void Dot11d_UpdateCountryIe(struct rtllib_device *dev, u8 
*pTaddr,
 
UPDATE_CIE_SRC(dev, pTaddr);
 
-   pDot11dInfo->CountryIeLen = CoutryIeLen;
-   memcpy(pDot11dInfo->CountryIeBuf, pCoutryIe, CoutryIeLen);
-   pDot11dInfo->State = DOT11D_STATE_LEARNED;
+   pDot11dInfo->country_len = CoutryIeLen;
+   memcpy(pDot11dInfo->country_buffer, pCoutryIe, CoutryIeLen);
+   pDot11dInfo->state = DOT11D_STATE_LEARNED;
 }
 
 void DOT11D_ScanComplete(struct rtllib_device *dev)
 {
struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(dev);
 
-   switch (pDot11dInfo->State) {
+   switch (pDot11dInfo->state) {
case DOT11D_STATE_LEARNED:
-   pDot11dInfo->State = DOT11D_STATE_DONE;
+   pDot11dInfo->state = DOT11D_STATE_DONE;
break;
case DOT11D_STATE_DONE:
Dot11d_Reset(dev);
diff --git a/drivers/staging/rtl8192e/dot11d.h 
b/drivers/staging/rtl8192e/dot11d.h
index 921e83e3dd47..9e5aca6ad9de 100644
--- a/drivers/staging/rtl8192e/dot11d.h
+++ b/drivers/staging/rtl8192e/dot11d.h
@@ -30,27 +30,27 @@ enum dot11d_state {
 };
 
 /**
- * struct rt_dot11d_info * @CountryIeLen: value greater than 0 if
- *   @CountryIeBuf contains valid country information element.
+ * struct rt_dot11d_info * @country_len: value greater than 0 if
+ *   @country_buffer contains valid country information element.
  * @channel_map: holds channel values
  * 0 - invalid,
  * 1 - valid (active scan),
  * 2 - valid (passive scan)
- * @CountryIeSrcAddr - Source AP of the country IE
+ * @country_src_addr - Source AP of the country IE
  */
 
 struct rt_dot11d_info {
-   bool bEnabled;
+   bool enabled;
 
-   u16 CountryIeLen

[PATCH 3/3] staging: rtl8192e: rename members of struct rtllib_device - style

2019-02-05 Thread Himadri Pandya
Rename following members of struct rtllib_device to fix checkpatch
warning: Avoid CamelCase

pDot11dInfo -> dot11d_info
bGlobalDomain -> global_domain
IbssStartChnl -> ibss_start_chnl

Signed-off-by: Himadri Pandya 
---
 drivers/staging/rtl8192e/dot11d.c | 58 +++
 drivers/staging/rtl8192e/dot11d.h |  2 +-
 drivers/staging/rtl8192e/rtllib.h |  6 +--
 drivers/staging/rtl8192e/rtllib_softmac.c | 12 ++---
 4 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/drivers/staging/rtl8192e/dot11d.c 
b/drivers/staging/rtl8192e/dot11d.c
index 7e489f0f3c41..ccf9c161aa7c 100644
--- a/drivers/staging/rtl8192e/dot11d.c
+++ b/drivers/staging/rtl8192e/dot11d.c
@@ -44,14 +44,14 @@ static struct channel_list channel_array[] = {
 
 void dot11d_init(struct rtllib_device *ieee)
 {
-   struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(ieee);
+   struct rt_dot11d_info *dot11d_info = GET_DOT11D_INFO(ieee);
 
-   pDot11dInfo->enabled = false;
+   dot11d_info->enabled = false;
 
-   pDot11dInfo->state = DOT11D_STATE_NONE;
-   pDot11dInfo->country_len = 0;
-   memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER + 1);
-   memset(pDot11dInfo->max_tx_power_list, 0xFF, MAX_CHANNEL_NUMBER + 1);
+   dot11d_info->state = DOT11D_STATE_NONE;
+   dot11d_info->country_len = 0;
+   memset(dot11d_info->channel_map, 0, MAX_CHANNEL_NUMBER + 1);
+   memset(dot11d_info->max_tx_power_list, 0xFF, MAX_CHANNEL_NUMBER + 1);
RESET_CIE_WATCHDOG(ieee);
 }
 EXPORT_SYMBOL(dot11d_init);
@@ -60,7 +60,7 @@ void Dot11d_Channelmap(u8 channel_plan, struct rtllib_device 
*ieee)
 {
int i, max_chan = 14, min_chan = 1;
 
-   ieee->bGlobalDomain = false;
+   ieee->global_domain = false;
 
if (channel_array[channel_plan].len != 0) {
memset(GET_DOT11D_INFO(ieee)->channel_map, 0,
@@ -76,22 +76,22 @@ void Dot11d_Channelmap(u8 channel_plan, struct 
rtllib_device *ieee)
 
switch (channel_plan) {
case COUNTRY_CODE_GLOBAL_DOMAIN:
-   ieee->bGlobalDomain = true;
+   ieee->global_domain = true;
for (i = 12; i <= 14; i++)
GET_DOT11D_INFO(ieee)->channel_map[i] = 2;
-   ieee->IbssStartChnl = 10;
+   ieee->ibss_start_chnl = 10;
ieee->ibss_maxjoin_chal = 11;
break;
 
case COUNTRY_CODE_WORLD_WIDE_13:
for (i = 12; i <= 13; i++)
GET_DOT11D_INFO(ieee)->channel_map[i] = 2;
-   ieee->IbssStartChnl = 10;
+   ieee->ibss_start_chnl = 10;
ieee->ibss_maxjoin_chal = 11;
break;
 
default:
-   ieee->IbssStartChnl = 1;
+   ieee->ibss_start_chnl = 1;
ieee->ibss_maxjoin_chal = 14;
break;
}
@@ -100,29 +100,29 @@ EXPORT_SYMBOL(Dot11d_Channelmap);
 
 void Dot11d_Reset(struct rtllib_device *ieee)
 {
-   struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(ieee);
+   struct rt_dot11d_info *dot11d_info = GET_DOT11D_INFO(ieee);
u32 i;
 
-   memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER + 1);
-   memset(pDot11dInfo->max_tx_power_list, 0xFF, MAX_CHANNEL_NUMBER + 1);
+   memset(dot11d_info->channel_map, 0, MAX_CHANNEL_NUMBER + 1);
+   memset(dot11d_info->max_tx_power_list, 0xFF, MAX_CHANNEL_NUMBER + 1);
for (i = 1; i <= 11; i++)
-   (pDot11dInfo->channel_map)[i] = 1;
+   (dot11d_info->channel_map)[i] = 1;
for (i = 12; i <= 14; i++)
-   (pDot11dInfo->channel_map)[i] = 2;
-   pDot11dInfo->state = DOT11D_STATE_NONE;
-   pDot11dInfo->country_len = 0;
+   (dot11d_info->channel_map)[i] = 2;
+   dot11d_info->state = DOT11D_STATE_NONE;
+   dot11d_info->country_len = 0;
RESET_CIE_WATCHDOG(ieee);
 }
 
 void Dot11d_UpdateCountryIe(struct rtllib_device *dev, u8 *pTaddr,
u16 CoutryIeLen, u8 *pCoutryIe)
 {
-   struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(dev);
+   struct rt_dot11d_info *dot11d_info = GET_DOT11D_INFO(dev);
u8 i, j, NumTriples, MaxChnlNum;
struct chnl_txpow_triple *pTriple;
 
-   memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER + 1);
-   memset(pDot11dInfo->max_tx_power_list, 0xFF, MAX_CHANNEL_NUMBER + 1);
+   memset(dot11d_info->channel_map, 0, MAX_CHANNEL_NUMBER + 1);
+   memset(dot11d_info->max_tx_power_list, 0xFF, MAX_CHANNEL_NUMBER + 1);
MaxChnlNum = 0;
NumTriples = (CoutryIeLen - 3) / 3;
pTriple = (struct chnl_txpow_triple *)(pCoutryIe + 3);
@@ -142,8 +142,8 @@ void Dot11d_UpdateCountryIe(struct rtllib_device *dev, u8 
*pTaddr,
}
 
for (j = 0; j < pTriple->num_chnls; j++) {
-   pDot11dInfo->channel_map[pTriple->first_chnl + j] = 1;
-

[PATCH 1/3] staging: rtl8192e: rename members of struct chnl_txpow_triple - style

2019-02-05 Thread Himadri Pandya
Rename following members of struct chnl_txpow_triple to avoid
checkpatch warning: Avoid CamelCase

FirstChnl -> first_chnl
NumChnls -> num_chnls
MaxTxPwrInDbm -> max_tx_power

Signed-off-by: Himadri Pandya 
---
 drivers/staging/rtl8192e/dot11d.c | 16 
 drivers/staging/rtl8192e/dot11d.h |  6 +++---
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/rtl8192e/dot11d.c 
b/drivers/staging/rtl8192e/dot11d.c
index be9a21062a2e..711e8264183e 100644
--- a/drivers/staging/rtl8192e/dot11d.c
+++ b/drivers/staging/rtl8192e/dot11d.c
@@ -127,25 +127,25 @@ void Dot11d_UpdateCountryIe(struct rtllib_device *dev, u8 
*pTaddr,
NumTriples = (CoutryIeLen - 3) / 3;
pTriple = (struct chnl_txpow_triple *)(pCoutryIe + 3);
for (i = 0; i < NumTriples; i++) {
-   if (MaxChnlNum >= pTriple->FirstChnl) {
+   if (MaxChnlNum >= pTriple->first_chnl) {
netdev_info(dev->dev,
"%s: Invalid country IE, skip it..1\n",
__func__);
return;
}
-   if (MAX_CHANNEL_NUMBER < (pTriple->FirstChnl +
-   pTriple->NumChnls)) {
+   if (MAX_CHANNEL_NUMBER < (pTriple->first_chnl +
+   pTriple->num_chnls)) {
netdev_info(dev->dev,
"%s: Invalid country IE, skip it..2\n",
__func__);
return;
}
 
-   for (j = 0; j < pTriple->NumChnls; j++) {
-   pDot11dInfo->channel_map[pTriple->FirstChnl + j] = 1;
-   pDot11dInfo->MaxTxPwrDbmList[pTriple->FirstChnl + j] =
-pTriple->MaxTxPowerInDbm;
-   MaxChnlNum = pTriple->FirstChnl + j;
+   for (j = 0; j < pTriple->num_chnls; j++) {
+   pDot11dInfo->channel_map[pTriple->first_chnl + j] = 1;
+   pDot11dInfo->MaxTxPwrDbmList[pTriple->first_chnl + j] =
+pTriple->max_tx_power;
+   MaxChnlNum = pTriple->first_chnl + j;
}
 
pTriple = (struct chnl_txpow_triple *)((u8 *)pTriple + 3);
diff --git a/drivers/staging/rtl8192e/dot11d.h 
b/drivers/staging/rtl8192e/dot11d.h
index 7fa3c4d963c4..921e83e3dd47 100644
--- a/drivers/staging/rtl8192e/dot11d.h
+++ b/drivers/staging/rtl8192e/dot11d.h
@@ -18,9 +18,9 @@
 #include "rtllib.h"
 
 struct chnl_txpow_triple {
-   u8 FirstChnl;
-   u8  NumChnls;
-   u8  MaxTxPowerInDbm;
+   u8 first_chnl;
+   u8 num_chnls;
+   u8 max_tx_power;
 };
 
 enum dot11d_state {
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 4/4] staging: iio: ad7780: moving ad7780 out of staging

2019-02-05 Thread Renato Lui Geh

Move ad7780 ADC driver out of staging and into the mainline.

The ad7780 is a sigma-delta analog to digital converter. This driver provides
reading voltage values and status bits from both the ad778x and ad717x series.
Its interface also allows writing on the FILTER and GAIN GPIO pins on the
ad778x.

Signed-off-by: Renato Lui Geh 
Signed-off-by: Giuliano Belinassi 
Co-developed-by: Giuliano Belinassi 
---
Changes in v3:
- Changes unrelated to moving the driver to main tree were resent as
  individual patches

drivers/iio/adc/Kconfig  |  13 ++
drivers/iio/adc/Makefile |   1 +
drivers/iio/adc/ad7780.c | 359 +++
drivers/staging/iio/adc/Kconfig  |  13 --
drivers/staging/iio/adc/Makefile |   1 -
drivers/staging/iio/adc/ad7780.c | 359 ---
6 files changed, 373 insertions(+), 373 deletions(-)
create mode 100644 drivers/iio/adc/ad7780.c
delete mode 100644 drivers/staging/iio/adc/ad7780.c

diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index f3cc7a31bce5..2cdee166d0e9 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -108,6 +108,19 @@ config AD7766
  To compile this driver as a module, choose M here: the module will be
  called ad7766.

+config AD7780
+   tristate "Analog Devices AD7780 and similar ADCs driver"
+   depends on SPI
+   depends on GPIOLIB || COMPILE_TEST
+   select AD_SIGMA_DELTA
+   help
+ Say yes here to build support for Analog Devices AD7170, AD7171,
+ AD7780 and AD7781 SPI analog to digital converters (ADC).
+ If unsure, say N (but it's safe to say "Y").
+
+ To compile this driver as a module, choose M here: the
+ module will be called ad7780.
+
config AD7791
tristate "Analog Devices AD7791 ADC driver"
depends on SPI
diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
index ea5031348052..b48852157115 100644
--- a/drivers/iio/adc/Makefile
+++ b/drivers/iio/adc/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_AD7606_IFACE_PARALLEL) += ad7606_par.o
obj-$(CONFIG_AD7606_IFACE_SPI) += ad7606_spi.o
obj-$(CONFIG_AD7606) += ad7606.o
obj-$(CONFIG_AD7766) += ad7766.o
+obj-$(CONFIG_AD7780) += ad7780.o
obj-$(CONFIG_AD7791) += ad7791.o
obj-$(CONFIG_AD7793) += ad7793.o
obj-$(CONFIG_AD7887) += ad7887.o
diff --git a/drivers/iio/adc/ad7780.c b/drivers/iio/adc/ad7780.c
new file mode 100644
index ..163e3c983598
--- /dev/null
+++ b/drivers/iio/adc/ad7780.c
@@ -0,0 +1,359 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * AD7170/AD7171 and AD7780/AD7781 SPI ADC driver
+ *
+ * Copyright 2011 Analog Devices Inc.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#define AD7780_RDY BIT(7)
+#define AD7780_FILTER  BIT(6)
+#define AD7780_ERR BIT(5)
+#define AD7780_ID1 BIT(4)
+#define AD7780_ID0 BIT(3)
+#define AD7780_GAINBIT(2)
+#define AD7780_PAT1BIT(1)
+#define AD7780_PAT0BIT(0)
+
+#define AD7780_PATTERN (AD7780_PAT0)
+#define AD7780_PATTERN_MASK(AD7780_PAT0 | AD7780_PAT1)
+
+#define AD7170_PAT2BIT(2)
+
+#define AD7170_PATTERN (AD7780_PAT0 | AD7170_PAT2)
+#define AD7170_PATTERN_MASK(AD7780_PAT0 | AD7780_PAT1 | AD7170_PAT2)
+
+#define AD7780_GAIN_GPIO   0
+#define AD7780_FILTER_GPIO 1
+
+#define AD7780_GAIN_MIDPOINT   64
+#define AD7780_FILTER_MIDPOINT 13350
+
+static const unsigned int ad778x_gain[2]  = { 1, 128 };
+static const unsigned int ad778x_odr_avail[2] = { 1, 16700 };
+
+struct ad7780_chip_info {
+   struct iio_chan_specchannel;
+   unsigned intpattern_mask;
+   unsigned intpattern;
+   boolis_ad778x;
+};
+
+struct ad7780_state {
+   const struct ad7780_chip_info   *chip_info;
+   struct regulator*reg;
+   struct gpio_desc*powerdown_gpio;
+   struct gpio_desc*gain_gpio;
+   struct gpio_desc*filter_gpio;
+   unsigned intgain;
+   unsigned intodr;
+   unsigned intint_vref_mv;
+
+   struct ad_sigma_delta sd;
+};
+
+enum ad7780_supported_device_ids {
+   ID_AD7170,
+   ID_AD7171,
+   ID_AD7780,
+   ID_AD7781,
+};
+
+static struct ad7780_state *ad_sigma_delta_to_ad7780(struct ad_sigma_delta *sd)
+{
+   return container_of(sd, struct ad7780_state, sd);
+}
+
+static int ad7780_set_mode(struct ad_sigma_delta *sigma_delta,
+  enum ad_sigma_delta_mode mode)
+{
+   struct ad7780_state *st = ad_sigma_delta_to_ad7780(sigma_delta);
+   unsigned int val;
+
+   switch (mode) {
+   case AD_SD_MODE_SINGLE:
+   case AD_SD_MODE_CONTINUOUS:
+   val = 1;

[PATCH v3 3/4] staging: iio: ad7780: add SPDX identifier

2019-02-05 Thread Renato Lui Geh

Add SPDX identifier (GPL-2.0) to the AD7780 driver.

Signed-off-by: Renato Lui Geh 
---
drivers/staging/iio/adc/ad7780.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
index 7804cd2b273e..163e3c983598 100644
--- a/drivers/staging/iio/adc/ad7780.c
+++ b/drivers/staging/iio/adc/ad7780.c
@@ -1,9 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/*
 * AD7170/AD7171 and AD7780/AD7781 SPI ADC driver
 *
 * Copyright 2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
 */

#include 
--
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 2/4] staging: iio: ad7780: move regulator to after GPIO init

2019-02-05 Thread Renato Lui Geh

To maintain consistency between ad7780_probe and ad7780_remove orders,
regulator initialization has been moved to after GPIO initializations.

Signed-off-by: Renato Lui Geh 
---
drivers/staging/iio/adc/ad7780.c | 26 +-
1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
index 6e4357800d31..7804cd2b273e 100644
--- a/drivers/staging/iio/adc/ad7780.c
+++ b/drivers/staging/iio/adc/ad7780.c
@@ -250,16 +250,6 @@ static int ad7780_probe(struct spi_device *spi)

ad_sd_init(&st->sd, indio_dev, spi, &ad7780_sigma_delta_info);

-   st->reg = devm_regulator_get(&spi->dev, "avdd");
-   if (IS_ERR(st->reg))
-   return PTR_ERR(st->reg);
-
-   ret = regulator_enable(st->reg);
-   if (ret) {
-   dev_err(&spi->dev, "Failed to enable specified AVdd supply\n");
-   return ret;
-   }
-
st->chip_info =
&ad7780_chip_info_tbl[spi_get_device_id(spi)->driver_data];

@@ -279,7 +269,7 @@ static int ad7780_probe(struct spi_device *spi)
ret = PTR_ERR(st->powerdown_gpio);
dev_err(&spi->dev, "Failed to request powerdown GPIO: %d\n",
ret);
-   goto error_disable_reg;
+   return ret;
}

if (st->chip_info->is_ad778x) {
@@ -290,7 +280,7 @@ static int ad7780_probe(struct spi_device *spi)
ret = PTR_ERR(st->gain_gpio);
dev_err(&spi->dev, "Failed to request gain GPIO: %d\n",
ret);
-   goto error_disable_reg;
+   return ret;
}

st->filter_gpio = devm_gpiod_get_optional(&spi->dev,
@@ -301,10 +291,20 @@ static int ad7780_probe(struct spi_device *spi)
dev_err(&spi->dev,
"Failed to request filter GPIO: %d\n",
ret);
-   goto error_disable_reg;
+   return ret;
}
}

+   st->reg = devm_regulator_get(&spi->dev, "avdd");
+   if (IS_ERR(st->reg))
+   return PTR_ERR(st->reg);
+
+   ret = regulator_enable(st->reg);
+   if (ret) {
+   dev_err(&spi->dev, "Failed to enable specified AVdd supply\n");
+   return ret;
+   }
+
ret = ad_sd_setup_buffer_and_trigger(indio_dev);
if (ret)
goto error_disable_reg;
--
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 1/4] staging: iio: ad7780: add gain & filter gpio support

2019-02-05 Thread Renato Lui Geh

Previously, the AD7780 driver only supported gpio for the 'powerdown'
pin. This commit adds suppport for the 'gain' and 'filter' pin.

Signed-off-by: Renato Lui Geh 
Signed-off-by: Giuliano Belinassi 
Co-developed-by: Giuliano Belinassi 
---
Changes in v3:
- Renamed ad7780_chip_info's filter to odr
- Renamed ad778x_filter to ad778x_odr_avail
- Changed vref variable from unsigned int to unsigned long long to
  avoid overflow
- Removed unnecessary AD_SD_CHANNEL macro

drivers/staging/iio/adc/ad7780.c | 95 ++--
1 file changed, 89 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
index c4a85789c2db..6e4357800d31 100644
--- a/drivers/staging/iio/adc/ad7780.c
+++ b/drivers/staging/iio/adc/ad7780.c
@@ -39,6 +39,15 @@
#define AD7170_PATTERN  (AD7780_PAT0 | AD7170_PAT2)
#define AD7170_PATTERN_MASK (AD7780_PAT0 | AD7780_PAT1 | AD7170_PAT2)

+#define AD7780_GAIN_GPIO   0
+#define AD7780_FILTER_GPIO 1
+
+#define AD7780_GAIN_MIDPOINT   64
+#define AD7780_FILTER_MIDPOINT 13350
+
+static const unsigned int ad778x_gain[2]  = { 1, 128 };
+static const unsigned int ad778x_odr_avail[2] = { 1, 16700 };
+
struct ad7780_chip_info {
struct iio_chan_specchannel;
unsigned intpattern_mask;
@@ -50,7 +59,11 @@ struct ad7780_state {
const struct ad7780_chip_info   *chip_info;
struct regulator*reg;
struct gpio_desc*powerdown_gpio;
-   unsigned intgain;
+   struct gpio_desc*gain_gpio;
+   struct gpio_desc*filter_gpio;
+   unsigned intgain;
+   unsigned intodr;
+   unsigned intint_vref_mv;

struct ad_sigma_delta sd;
};
@@ -104,17 +117,65 @@ static int ad7780_read_raw(struct iio_dev *indio_dev,
voltage_uv = regulator_get_voltage(st->reg);
if (voltage_uv < 0)
return voltage_uv;
-   *val = (voltage_uv / 1000) * st->gain;
+   voltage_uv /= 1000;
+   *val = voltage_uv * st->gain;
*val2 = chan->scan_type.realbits - 1;
+   st->int_vref_mv = voltage_uv;
return IIO_VAL_FRACTIONAL_LOG2;
case IIO_CHAN_INFO_OFFSET:
*val = -(1 << (chan->scan_type.realbits - 1));
return IIO_VAL_INT;
+   case IIO_CHAN_INFO_SAMP_FREQ:
+   *val = st->odr;
+   return IIO_VAL_INT;
}

return -EINVAL;
}

+static int ad7780_write_raw(struct iio_dev *indio_dev,
+   struct iio_chan_spec const *chan,
+   int val,
+   int val2,
+   long m)
+{
+   struct ad7780_state *st = iio_priv(indio_dev);
+   const struct ad7780_chip_info *chip_info = st->chip_info;
+   unsigned long long vref;
+   unsigned int full_scale, gain;
+
+   if (!chip_info->is_ad778x)
+   return 0;
+
+   switch (m) {
+   case IIO_CHAN_INFO_SCALE:
+   if (val != 0)
+   return -EINVAL;
+
+   vref = st->int_vref_mv * 100LL;
+   full_scale = 1 << (chip_info->channel.scan_type.realbits - 1);
+   gain = DIV_ROUND_CLOSEST(vref, full_scale);
+   gain = DIV_ROUND_CLOSEST(gain, val2);
+   st->gain = gain;
+   if (gain < AD7780_GAIN_MIDPOINT)
+   gain = 0;
+   else
+   gain = 1;
+   gpiod_set_value(st->gain_gpio, gain);
+   break;
+   case IIO_CHAN_INFO_SAMP_FREQ:
+   if (1000*val + val2/1000 < AD7780_FILTER_MIDPOINT)
+   val = 0;
+   else
+   val = 1;
+   st->odr = ad778x_odr_avail[val];
+   gpiod_set_value(st->filter_gpio, val);
+   break;
+   }
+
+   return 0;
+}
+
static int ad7780_postprocess_sample(struct ad_sigma_delta *sigma_delta,
 unsigned int raw_sample)
{
@@ -126,10 +187,8 @@ static int ad7780_postprocess_sample(struct ad_sigma_delta 
*sigma_delta,
return -EIO;

if (chip_info->is_ad778x) {
-   if (raw_sample & AD7780_GAIN)
-   st->gain = 1;
-   else
-   st->gain = 128;
+   st->gain = ad778x_gain[raw_sample & AD7780_GAIN];
+   st->odr = ad778x_odr_avail[raw_sample & AD7780_FILTER];
}

return 0;
@@ -173,6 +232,7 @@ static const struct ad7780_chip_info ad7780_chip_info_tbl[] 
= {

static const struct iio_info ad7780_info = {
.read_raw = ad7780_read_raw,
+   .write_raw = ad7780_write_raw,
};

static int ad7780_probe(struct spi_device *spi)
@@ -222,6 +282,

[PATCH v3 0/4] staging: iio: ad7780: move out of staging

2019-02-05 Thread Renato Lui Geh

This series of patches adds user input to ad7780 'gain' & 'filter' gpio
pins, moves regulator initialization to after gpio initialization to
maintain consistency between probe and remove, adds SPDX to the driver's
license, and moves the ad7780 to the mainline.

Renato Lui Geh (4):
 staging: iio: ad7780: add gain & filter gpio support
 staging: iio: ad7780: move regulator to after GPIO init
 staging: iio: ad7780: add SPDX identifier
 staging: iio: ad7780: moving ad7780 out of staging

Changelog:
*v3
- SPDX and regulator init as patches
- Renamed filter to odr and ad778x_filter to ad778x_odr_avail
- Removed unnecessary regulator disabling
- Removed unnecessary AD_SD_CHANNEL macro
- Changed unsigned int to unsigned long long to avoid overflow

drivers/iio/adc/Kconfig  |  13 ++
drivers/iio/adc/Makefile |   1 +
drivers/iio/adc/ad7780.c | 359 +++
drivers/staging/iio/adc/Kconfig  |  13 --
drivers/staging/iio/adc/Makefile |   1 -
drivers/staging/iio/adc/ad7780.c | 277 
6 files changed, 373 insertions(+), 291 deletions(-)
create mode 100644 drivers/iio/adc/ad7780.c
delete mode 100644 drivers/staging/iio/adc/ad7780.c

--
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/3] sched/wait: introduce wait_event_freezable_hrtimeout

2019-02-05 Thread Joel Fernandes
On Fri, Feb 01, 2019 at 06:38:35AM +0100, Hugo Lefeuvre wrote:
> introduce wait_event_freezable_hrtimeout, an interruptible and freezable
> version of wait_event_hrtimeout.
> 
> Among others this helper will allow for simplifications in
> staging/android/vsoc.c.
> 
> Signed-off-by: Hugo Lefeuvre 
> ---

Reviewed-by: Joel Fernandes (Google) 

thanks,

 - Joel

>  include/linux/wait.h | 25 +
>  1 file changed, 21 insertions(+), 4 deletions(-)
> 
> diff --git a/include/linux/wait.h b/include/linux/wait.h
> index 5f3efabc36f4..c4cf5113f58a 100644
> --- a/include/linux/wait.h
> +++ b/include/linux/wait.h
> @@ -483,7 +483,7 @@ do {  
> \
>   __ret;  
> \
>  })
>  
> -#define __wait_event_hrtimeout(wq_head, condition, timeout, state)   
> \
> +#define __wait_event_hrtimeout(wq_head, condition, timeout, state, cmd)  
> \
>  ({   
> \
>   int __ret = 0;  
> \
>   struct hrtimer_sleeper __t; 
> \
> @@ -500,7 +500,7 @@ do {  
> \
>   __ret = -ETIME; 
> \
>   break;  
> \
>   }   
> \
> - schedule());
> \
> + cmd);   
> \
>   
> \
>   hrtimer_cancel(&__t.timer); 
> \
>   destroy_hrtimer_on_stack(&__t.timer);   
> \
> @@ -529,7 +529,23 @@ do { 
> \
>   might_sleep();  
> \
>   if (!(condition))   
> \
>   __ret = __wait_event_hrtimeout(wq_head, condition, timeout, 
> \
> -TASK_UNINTERRUPTIBLE);   
> \
> +TASK_UNINTERRUPTIBLE,
> \
> +schedule()); 
> \
> + __ret;  
> \
> +})
> +
> +/*
> + * like wait_event_hrtimeout() -- except it uses TASK_INTERRUPTIBLE to avoid
> + * increasing load and is freezable.
> + */
> +#define wait_event_freezable_hrtimeout(wq_head, condition, timeout)  
> \
> +({   
> \
> + int __ret = 0;  
> \
> + might_sleep();  
> \
> + if (!(condition))   
> \
> + __ret = __wait_event_hrtimeout(wq_head, condition, timeout, 
> \
> +TASK_INTERRUPTIBLE,  
> \
> +freezable_schedule());   
> \
>   __ret;  
> \
>  })
>  
> @@ -555,7 +571,8 @@ do {  
> \
>   might_sleep();  
> \
>   if (!(condition))   
> \
>   __ret = __wait_event_hrtimeout(wq, condition, timeout,  
> \
> -TASK_INTERRUPTIBLE); 
> \
> +TASK_INTERRUPTIBLE,  
> \
> +schedule()); 
> \
>   __ret;  
> \
>  })
>  
> -- 
> 2.20.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/3] sched/wait: use freezable_schedule when possible

2019-02-05 Thread Joel Fernandes
On Fri, Feb 01, 2019 at 06:38:05AM +0100, Hugo Lefeuvre wrote:
> Replace schedule(); try_to_freeze() by freezable_schedule().
> 
> Tasks calling freezable_schedule() set the PF_FREEZER_SKIP flag
> before calling schedule(). Unlike tasks calling schedule();
> try_to_freeze() tasks calling freezable_schedule() are not awaken by
> try_to_freeze_tasks(). Instead they call try_to_freeze() when they
> wake up if the freeze is still underway.
> 
> It is not a problem since sleeping tasks can't do anything which isn't
> allowed for a frozen task while sleeping.
> 
> The result is a potential performance gain during freeze, since less
> tasks have to be awaken.

Reviewed-by: Joel Fernandes (Google) 

thanks,

 - Joel

> 
> Signed-off-by: Hugo Lefeuvre 
> ---
>  include/linux/wait.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/wait.h b/include/linux/wait.h
> index ed7c122cb31f..5f3efabc36f4 100644
> --- a/include/linux/wait.h
> +++ b/include/linux/wait.h
> @@ -308,7 +308,7 @@ do {  
> \
>  
>  #define __wait_event_freezable(wq_head, condition)   
> \
>   ___wait_event(wq_head, condition, TASK_INTERRUPTIBLE, 0, 0, 
> \
> - schedule(); try_to_freeze())
> + freezable_schedule())
>  
>  /**
>   * wait_event_freezable - sleep (or freeze) until a condition gets true
> @@ -367,7 +367,7 @@ do {  
> \
>  #define __wait_event_freezable_timeout(wq_head, condition, timeout)  
> \
>   ___wait_event(wq_head, ___wait_cond_timeout(condition), 
> \
> TASK_INTERRUPTIBLE, 0, timeout,   
> \
> -   __ret = schedule_timeout(__ret); try_to_freeze())
> +   __ret = freezable_schedule_timeout(__ret))
>  
>  /*
>   * like wait_event_timeout() -- except it uses TASK_INTERRUPTIBLE to avoid
> @@ -588,7 +588,7 @@ do {  
> \
>  
>  #define __wait_event_freezable_exclusive(wq, condition)  
> \
>   ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 1, 0,  
> \
> - schedule(); try_to_freeze())
> + freezable_schedule())
>  
>  #define wait_event_freezable_exclusive(wq, condition)
> \
>  ({   
> \
> -- 
> 2.20.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/2] staging: android: ashmem: Don't call fallocate() with ashmem_mutex held.

2019-02-05 Thread Joel Fernandes
On Tue, Feb 05, 2019 at 07:28:40PM +0900, Tetsuo Handa wrote:
> syzbot is hitting lockdep warnings [1][2][3]. This patch tries to fix
> the warning by eliminating ashmem_shrink_scan() => {shmem|vfs}_fallocate()
> sequence.
> 
> [1] 
> https://syzkaller.appspot.com/bug?id=87c399f6fa6955006080b24142e2ce7680295ad4
> [2] 
> https://syzkaller.appspot.com/bug?id=7ebea492de7521048355fc84210220e1038a7908
> [3] 
> https://syzkaller.appspot.com/bug?id=e02419c12131c24e2a957ea050c2ab6dcbbc3270
> 
> Reported-by: syzbot 
> Reported-by: syzbot 
> Reported-by: syzbot 
> Signed-off-by: Tetsuo Handa 
> Cc: sta...@vger.kernel.org
> ---

Please in the future, include some information about what changed from
previous patches, or atleast add a cover letter. And use patch revision
numbers. It is hard to know what changed from previous review.

This looks good to me,

Acked-by: Joel Fernandes (Google) 

thanks,

 - Joel

>  drivers/staging/android/ashmem.c | 25 -
>  1 file changed, 20 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/android/ashmem.c 
> b/drivers/staging/android/ashmem.c
> index 90a8a9f1ac7d..ade8438a827a 100644
> --- a/drivers/staging/android/ashmem.c
> +++ b/drivers/staging/android/ashmem.c
> @@ -75,6 +75,9 @@ struct ashmem_range {
>  /* LRU list of unpinned pages, protected by ashmem_mutex */
>  static LIST_HEAD(ashmem_lru_list);
>  
> +static atomic_t ashmem_shrink_inflight = ATOMIC_INIT(0);
> +static DECLARE_WAIT_QUEUE_HEAD(ashmem_shrink_wait);
> +
>  /*
>   * long lru_count - The count of pages on our LRU list.
>   *
> @@ -438,7 +441,6 @@ static int ashmem_mmap(struct file *file, struct 
> vm_area_struct *vma)
>  static unsigned long
>  ashmem_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
>  {
> - struct ashmem_range *range, *next;
>   unsigned long freed = 0;
>  
>   /* We might recurse into filesystem code, so bail out if necessary */
> @@ -448,21 +450,33 @@ ashmem_shrink_scan(struct shrinker *shrink, struct 
> shrink_control *sc)
>   if (!mutex_trylock(&ashmem_mutex))
>   return -1;
>  
> - list_for_each_entry_safe(range, next, &ashmem_lru_list, lru) {
> + while (!list_empty(&ashmem_lru_list)) {
> + struct ashmem_range *range =
> + list_first_entry(&ashmem_lru_list, typeof(*range), lru);
>   loff_t start = range->pgstart * PAGE_SIZE;
>   loff_t end = (range->pgend + 1) * PAGE_SIZE;
> + struct file *f = range->asma->file;
>  
> - range->asma->file->f_op->fallocate(range->asma->file,
> - FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
> - start, end - start);
> + get_file(f);
> + atomic_inc(&ashmem_shrink_inflight);
>   range->purged = ASHMEM_WAS_PURGED;
>   lru_del(range);
>  
>   freed += range_size(range);
> + mutex_unlock(&ashmem_mutex);
> + f->f_op->fallocate(f,
> +FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
> +start, end - start);
> + fput(f);
> + if (atomic_dec_and_test(&ashmem_shrink_inflight))
> + wake_up_all(&ashmem_shrink_wait);
> + if (!mutex_trylock(&ashmem_mutex))
> + goto out;
>   if (--sc->nr_to_scan <= 0)
>   break;
>   }
>   mutex_unlock(&ashmem_mutex);
> +out:
>   return freed;
>  }
>  
> @@ -713,6 +727,7 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, 
> unsigned long cmd,
>   return -EFAULT;
>  
>   mutex_lock(&ashmem_mutex);
> + wait_event(ashmem_shrink_wait, !atomic_read(&ashmem_shrink_inflight));
>  
>   if (!asma->file)
>   goto out_unlock;
> -- 
> 2.17.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/2] staging: android: ashmem: Don't allow range_alloc() to fail.

2019-02-05 Thread Joel Fernandes
On Tue, Feb 05, 2019 at 07:28:41PM +0900, Tetsuo Handa wrote:
> ashmem_pin() is calling range_shrink() without checking whether
> range_alloc() succeeded. Since memory allocation fault injection might
> force range_alloc() to fail while range_alloc() is called for only once
> for one ioctl() request, make range_alloc() not to fail.

Why does this not need to fail? I am worried your change will introduce
unwanted endless looping in the kernel instead of gracefully failing a
pin/unpin request.

Unless there is a good reason, I suggest to drop this patch from the series;
but let us discuss more if you want.

thanks,

 - Joel

>From the docs:
__GFP_NOFAIL - Indicate that this allocation is in no way allowed to fail 
(think twice before using).
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6656: Use the correct style for SPDX license Identifier

2019-02-05 Thread Nishad Kamdar
This patch corrects the style for SPDX license Identifier in mac.h
by using "/* */" in place of "//" as per Linux kernel licensing rules.
Issue found by checkpatch.

Signed-off-by: Nishad Kamdar 
---
 drivers/staging/vt6656/mac.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vt6656/mac.h b/drivers/staging/vt6656/mac.h
index 94e700fcd0b6..75166020f7c6 100644
--- a/drivers/staging/vt6656/mac.h
+++ b/drivers/staging/vt6656/mac.h
@@ -1,5 +1,5 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
+/* SPDX-License-Identifier: GPL-2.0+
+ *
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
  *
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Need this for your photos?

2019-02-05 Thread Stacy

Need to retouch your photos?  Deep etching or masking for your photos?

We are the studio who can do those service for your photos.

Please send photos to start

Thanks,
Stacy


















Ingolsdtadt


Seevedtal

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 02/12] bnxt: Implement ndo_get_port_parent_id()

2019-02-05 Thread kbuild test robot
Hi Florian,

I love your patch! Yet something to improve:

[auto build test ERROR on net/master]
[also build test ERROR on v5.0-rc4 next-20190205]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Florian-Fainelli/net-Introduce-ndo_get_port_parent_id/20190205-163356
config: i386-randconfig-b0-02041055 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c: In function 
'bnxt_vf_rep_get_port_parent_id':
>> drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c:248:50: error: 'attr' 
>> undeclared (first use in this function)
 return bnxt_get_port_parent_id(vf_rep->bp->dev, attr);
 ^
   drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c:248:50: note: each undeclared 
identifier is reported only once for each function it appears in
   drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c:249:1: warning: control 
reaches end of non-void function [-Wreturn-type]
}
^

vim +/attr +248 drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c

   239  
   240  static int bnxt_vf_rep_get_port_parent_id(struct net_device *dev,
   241struct netdev_phys_item_id 
*ppid)
   242  {
   243  struct bnxt_vf_rep *vf_rep = netdev_priv(dev);
   244  
   245  /* as only PORT_PARENT_ID is supported currently use common code
   246   * between PF and VF-rep for now.
   247   */
 > 248  return bnxt_get_port_parent_id(vf_rep->bp->dev, attr);
   249  }
   250  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v12 00/13] media: staging/imx7: add i.MX7 media driver

2019-02-05 Thread Hans Verkuil
On 2/4/19 1:00 PM, Rui Miguel Silva wrote:
> Hi,
> This series introduces the Media driver to work with the i.MX7 SoC. it uses 
> the
> already existing imx media core drivers but since the i.MX7, contrary to
> i.MX5/6, do not have an IPU and because of that some changes in the imx media
> core are made along this series to make it support that case.
> 
> This patches adds CSI and MIPI-CSI2 drivers for i.MX7, along with several
> configurations changes for this to work as a capture subsystem. Some bugs are
> also fixed along the line. And necessary documentation.
> 
> For a more detailed view of the capture paths, pads links in the i.MX7 please
> take a look at the documentation in PATCH 10.
> 
> The system used to test and develop this was the Warp7 board with an OV2680
> sensor, which output format is 10-bit bayer. So, only MIPI interface was
> tested, a scenario with an parallel input would nice to have.
> 
> Bellow goes an example of the output of the pads and links and the output of
> v4l2-compliance testing.
> 
> The v4l-utils version used is:
> v4l2-compliance SHA: 1a6c8fe9a65c26e78ba34bd4aa2df28ede7d00cb, 32 bits
> 
> The Media Driver fail some tests but this failures are coming from code out of
> scope of this series (imx-capture), and some from the sensor OV2680
> but that I think not related with the sensor driver but with the testing and
> core.
> 
> The csi and mipi-csi entities pass all compliance tests.

Darn, I was hoping to merge this, but this series is out of date with the
latest imx code in the master branch. Can you rebase this series?

Thanks!

Hans

> 
> Cheers,
> Rui
> 
> v11->v12:
>   Sakari:
> - check v4l2_ctrl_handler_free and init when exposed to userspace
> - check csi_remove missing v4l2_async_notifier_unregister
> - media device unregister before ctrl_handler_free
> - GPL => GPL v2
> - Fix squash of CSI patches, issue on v11
> - add Acked-by: Sakari Ailus  10--13
> - mipi_s_stream check for ret < 0 and call pm_runtime_put_noidle
> - use __maybe_unused in pm functions
> - Extra space before labels
> 
> v10->v11:
>   Sakari:
> - Remove cleanup functions in dev-common and do direct calls
> - Fix notifier cleanup on error path
> 
>   Philipp Zabel:
> - Add reviewed tag to video mux patch 12/13
> 
> v9->v10:
>   Hans:
>   - move dt-bindings patch up in the series to avoid checkpatch warnings
>   - Fix SPDX tag
> 
>   Sakari:
>   - use debugfs and drop driver parameters
>   - use dev_*() macros all over the place, drop v4l2_*() ones
>   - use clk_bulk
>   - give control to power state to runtime PM
>   - unsigned and const for some objects
> 
> v8->v9:
> Hans Verkuil:
>  - Fix issues detected by checkpatch strict, still some left:
>  - bigger kconfig option description
>  - some alignement parenthesis that were left as they are, to be more
>  readable 
>  - added new patch (PATCH13) for Maintainers update
>  - SPDX in documentation rst file
> Sakari Ailus:
>  - remove pad check in csi, this is done by core already
>  - destroy mutex in probe error path (add label)
>  - swap order in driver release
>  - initialize endpoint in stack
>  - use clk_bulk
> kbuild test robot:
>  - add the missing imx-media-dev-common.c in patch 1/13
>  - remove OWNER of module csis
> Myself:
>  - add MAINTAINERS entries - new patch
> 
> v7->v8:
> Myself:
>  - rebase to latest linux-next (s/V4L2_MBUS_CSI2/V4L2_MBUS_CSI2_DPHY/)
>  - Rebuild and test with latest v4l2-compliance
>  - add Sakari reviewed-by tag to dt-bindings
> 
> v6->v7:
> Myself:
>  - Clock patches removed from this version since they were already merged
>  - Rebuild and test with the latest v4l2-compliance
>  - Add patch to video-mux regarding bayer formats
>  - remove reference to dependent patch serie (was already merged)
> 
> Sakari Ailus:
>  - add port and endpoint explanantions
>  - fix some wording should -> shall
> 
> v5->v6:
> Rob Herring:
>  - rename power-domain node name from: pgc-power-domain to power-domain
>  - change mux-control-cells to 0
>  - remove bus-width from mipi bindings and dts
>  - remove err... regarding clock names line
>  - remove clk-settle from example
>  - split mipi-csi2 and csi bindings per file
>  - add OF graph description to CSI
> 
> Philipp Zabel:
>  - rework group IDs and rename them with an _IPU_ prefix, this allowed to 
> remove
>the ipu_present flag need.
> 
> v4->v5:
> Sakari Ailus:
>  - fix remove of the capture entries in dts bindings in the right patch
> 
> Stephen Boyd:
>  - Send all series to clk list
> 
> v3->v4:
> Philipp Zabel:
>  - refactor initialization code from media device probe to be possible to used
>from other modules
>  - Remove index of csi from all accurrencs (dts, code, documentation)
>  - Remove need for capture node for imx7
>  - fix pinctrl for ov2680
>  - add reviewed tag to add multiplexer controls patch
> 
> Fabio Estevam:
>  - remove always on from new regulator
> 
> Randy Dunlap:
>  

Re: [PATCH v12 00/13] media: staging/imx7: add i.MX7 media driver

2019-02-05 Thread Rui Miguel Silva

Hi Sakari,
On Tue 05 Feb 2019 at 11:14, Sakari Ailus wrote:

Hi Rui,

On Mon, Feb 04, 2019 at 12:00:26PM +, Rui Miguel Silva 
wrote:

Hi,
This series introduces the Media driver to work with the i.MX7 
SoC. it uses the
already existing imx media core drivers but since the i.MX7, 
contrary to
i.MX5/6, do not have an IPU and because of that some changes in 
the imx media

core are made along this series to make it support that case.

This patches adds CSI and MIPI-CSI2 drivers for i.MX7, along 
with several
configurations changes for this to work as a capture subsystem. 
Some bugs are

also fixed along the line. And necessary documentation.

For a more detailed view of the capture paths, pads links in 
the i.MX7 please

take a look at the documentation in PATCH 10.

The system used to test and develop this was the Warp7 board 
with an OV2680
sensor, which output format is 10-bit bayer. So, only MIPI 
interface was

tested, a scenario with an parallel input would nice to have.

Bellow goes an example of the output of the pads and links and 
the output of

v4l2-compliance testing.

The v4l-utils version used is:
v4l2-compliance SHA: 1a6c8fe9a65c26e78ba34bd4aa2df28ede7d00cb, 
32 bits


The Media Driver fail some tests but this failures are coming 
from code out of
scope of this series (imx-capture), and some from the sensor 
OV2680
but that I think not related with the sensor driver but with 
the testing and

core.

The csi and mipi-csi entities pass all compliance tests.

Cheers,
Rui

v11->v12:
  Sakari:
- check v4l2_ctrl_handler_free and init when exposed to 
userspace

- check csi_remove missing v4l2_async_notifier_unregister
- media device unregister before ctrl_handler_free
- GPL => GPL v2
- Fix squash of CSI patches, issue on v11
- add Acked-by: Sakari Ailus  
10--13
- mipi_s_stream check for ret < 0 and call 
pm_runtime_put_noidle

- use __maybe_unused in pm functions
- Extra space before labels


For patches 1, 2 and 4:

Acked-by: Sakari Ailus 


Thanks for all your reviews, I did not add this before, because I
messed the patch order in v11.

---
Cheers,
Rui

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 12/12] net: Get rid of SWITCHDEV_ATTR_ID_PORT_PARENT_ID

2019-02-05 Thread kbuild test robot
Hi Florian,

I love your patch! Yet something to improve:

[auto build test ERROR on net/master]
[also build test ERROR on next-20190205]
[cannot apply to v5.0-rc4]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Florian-Fainelli/net-Introduce-ndo_get_port_parent_id/20190205-163356
config: nds32-allmodconfig (attached as .config)
compiler: nds32le-linux-gcc (GCC) 6.4.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=6.4.0 make.cross ARCH=nds32 

All errors (new ones prefixed by >>):

   net/ipv4/ipmr.c: In function 'vif_add':
>> net/ipv4/ipmr.c:920:2: error: 'attr' undeclared (first use in this function)
 attr.orig_dev = dev;
 ^~~~
   net/ipv4/ipmr.c:920:2: note: each undeclared identifier is reported only 
once for each function it appears in

vim +/attr +920 net/ipv4/ipmr.c

^1da177e4 Linus Torvalds  2005-04-16  835  
0c12295a7 Patrick McHardy 2010-04-13  836  static int vif_add(struct net 
*net, struct mr_table *mrt,
0c12295a7 Patrick McHardy 2010-04-13  837  struct vifctl *vifc, 
int mrtsock)
^1da177e4 Linus Torvalds  2005-04-16  838  {
ca3b84139 Florian Fainelli2019-02-04  839   struct netdev_phys_item_id ppid 
= { };
f95ad5036 Florian Fainelli2019-02-04  840   const struct net_device_ops 
*ops;
^1da177e4 Linus Torvalds  2005-04-16  841   int vifi = vifc->vifc_vifi;
0c12295a7 Patrick McHardy 2010-04-13  842   struct vif_device *v = 
&mrt->vif_table[vifi];
^1da177e4 Linus Torvalds  2005-04-16  843   struct net_device *dev;
^1da177e4 Linus Torvalds  2005-04-16  844   struct in_device *in_dev;
d607032db Wang Chen   2008-07-14  845   int err;
^1da177e4 Linus Torvalds  2005-04-16  846  
^1da177e4 Linus Torvalds  2005-04-16  847   /* Is vif busy ? */
0c12295a7 Patrick McHardy 2010-04-13  848   if (VIF_EXISTS(mrt, vifi))
^1da177e4 Linus Torvalds  2005-04-16  849   return -EADDRINUSE;
^1da177e4 Linus Torvalds  2005-04-16  850  
^1da177e4 Linus Torvalds  2005-04-16  851   switch (vifc->vifc_flags) {
^1da177e4 Linus Torvalds  2005-04-16  852   case VIFF_REGISTER:
1973a4ea6 Nikolay Aleksandrov 2015-11-26  853   if 
(!ipmr_pimsm_enabled())
c316c629f Nikolay Aleksandrov 2015-11-21  854   return -EINVAL;
c316c629f Nikolay Aleksandrov 2015-11-21  855   /* Special Purpose VIF 
in PIM
^1da177e4 Linus Torvalds  2005-04-16  856* All the packets will 
be sent to the daemon
^1da177e4 Linus Torvalds  2005-04-16  857*/
0c12295a7 Patrick McHardy 2010-04-13  858   if 
(mrt->mroute_reg_vif_num >= 0)
^1da177e4 Linus Torvalds  2005-04-16  859   return 
-EADDRINUSE;
f0ad0860d Patrick McHardy 2010-04-13  860   dev = ipmr_reg_vif(net, 
mrt);
^1da177e4 Linus Torvalds  2005-04-16  861   if (!dev)
^1da177e4 Linus Torvalds  2005-04-16  862   return -ENOBUFS;
d607032db Wang Chen   2008-07-14  863   err = 
dev_set_allmulti(dev, 1);
d607032db Wang Chen   2008-07-14  864   if (err) {
d607032db Wang Chen   2008-07-14  865   
unregister_netdevice(dev);
7dc00c82c Wang Chen   2008-07-14  866   dev_put(dev);
d607032db Wang Chen   2008-07-14  867   return err;
d607032db Wang Chen   2008-07-14  868   }
^1da177e4 Linus Torvalds  2005-04-16  869   break;
^1da177e4 Linus Torvalds  2005-04-16  870   case VIFF_TUNNEL:
4feb88e5c Benjamin Thery  2009-01-22  871   dev = 
ipmr_new_tunnel(net, vifc);
^1da177e4 Linus Torvalds  2005-04-16  872   if (!dev)
^1da177e4 Linus Torvalds  2005-04-16  873   return -ENOBUFS;
d607032db Wang Chen   2008-07-14  874   err = 
dev_set_allmulti(dev, 1);
d607032db Wang Chen   2008-07-14  875   if (err) {
d607032db Wang Chen   2008-07-14  876   
ipmr_del_tunnel(dev, vifc);
7dc00c82c Wang Chen   2008-07-14  877   dev_put(dev);
d607032db Wang Chen   2008-07-14  878   return err;
d607032db Wang Chen   2008-07-14  879   }
^1da177e4 Linus Torvalds  2005-04-16  880   break;
ee5e81f00 Ilia K  2009-09-16  881   case VIFF_USE_IFINDEX:
^1da177e4 Linus Torvalds  2005-04-16  882   case 0:
ee5e81f00 Ilia K  2009-09-16  883   if (vifc->vifc_flags == 
VIFF_USE_IFINDEX) {
ee5e81f00 Ilia K  2009-09-16  884   dev = 
dev_get_by_index(net, vifc->vifc_lcl_ifindex);
51456b291 Ian Morris  2015-04

Re: [PATCH v12 00/13] media: staging/imx7: add i.MX7 media driver

2019-02-05 Thread Sakari Ailus
Hi Rui,

On Mon, Feb 04, 2019 at 12:00:26PM +, Rui Miguel Silva wrote:
> Hi,
> This series introduces the Media driver to work with the i.MX7 SoC. it uses 
> the
> already existing imx media core drivers but since the i.MX7, contrary to
> i.MX5/6, do not have an IPU and because of that some changes in the imx media
> core are made along this series to make it support that case.
> 
> This patches adds CSI and MIPI-CSI2 drivers for i.MX7, along with several
> configurations changes for this to work as a capture subsystem. Some bugs are
> also fixed along the line. And necessary documentation.
> 
> For a more detailed view of the capture paths, pads links in the i.MX7 please
> take a look at the documentation in PATCH 10.
> 
> The system used to test and develop this was the Warp7 board with an OV2680
> sensor, which output format is 10-bit bayer. So, only MIPI interface was
> tested, a scenario with an parallel input would nice to have.
> 
> Bellow goes an example of the output of the pads and links and the output of
> v4l2-compliance testing.
> 
> The v4l-utils version used is:
> v4l2-compliance SHA: 1a6c8fe9a65c26e78ba34bd4aa2df28ede7d00cb, 32 bits
> 
> The Media Driver fail some tests but this failures are coming from code out of
> scope of this series (imx-capture), and some from the sensor OV2680
> but that I think not related with the sensor driver but with the testing and
> core.
> 
> The csi and mipi-csi entities pass all compliance tests.
> 
> Cheers,
> Rui
> 
> v11->v12:
>   Sakari:
> - check v4l2_ctrl_handler_free and init when exposed to userspace
> - check csi_remove missing v4l2_async_notifier_unregister
> - media device unregister before ctrl_handler_free
> - GPL => GPL v2
> - Fix squash of CSI patches, issue on v11
> - add Acked-by: Sakari Ailus  10--13
> - mipi_s_stream check for ret < 0 and call pm_runtime_put_noidle
> - use __maybe_unused in pm functions
> - Extra space before labels

For patches 1, 2 and 4:

Acked-by: Sakari Ailus 

Thanks!

-- 
Sakari Ailus
sakari.ai...@linux.intel.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: sm750fb: Rename setDisplayControl to set_display_control - style

2019-02-05 Thread Jin Chen
Fix checkpatch.pl warning:
CHECK: Avoid CamelCase: 

Signed-off-by: Jin Chen 
---
 drivers/staging/sm750fb/ddk750_display.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_display.c 
b/drivers/staging/sm750fb/ddk750_display.c
index 1273e7d..f38051e 100644
--- a/drivers/staging/sm750fb/ddk750_display.c
+++ b/drivers/staging/sm750fb/ddk750_display.c
@@ -5,7 +5,7 @@
 #include "ddk750_power.h"
 #include "ddk750_dvi.h"
 
-static void setDisplayControl(int ctrl, int disp_state)
+static void set_display_control(int ctrl, int disp_state)
 {
/* state != 0 means turn on both timing & plane en_bit */
unsigned long reg, val, reserved;
@@ -137,12 +137,12 @@ void ddk750_setLogicalDispOut(enum disp_output output)
 
if (output & PRI_TP_USAGE) {
/* set primary timing and plane en_bit */
-   setDisplayControl(0, (output & PRI_TP_MASK) >> PRI_TP_OFFSET);
+   set_display_control(0, (output & PRI_TP_MASK) >> PRI_TP_OFFSET);
}
 
if (output & SEC_TP_USAGE) {
/* set secondary timing and plane en_bit*/
-   setDisplayControl(1, (output & SEC_TP_MASK) >> SEC_TP_OFFSET);
+   set_display_control(1, (output & SEC_TP_MASK) >> SEC_TP_OFFSET);
}
 
if (output & PNL_SEQ_USAGE) {
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: wlan-ng: formatting change in cfg80211.c

2019-02-05 Thread K Hodges
Resolve "Line over 80 characters" warning from checkpatch

Signed-off-by: K Hodges 
---
 drivers/staging/wlan-ng/cfg80211.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/wlan-ng/cfg80211.c 
b/drivers/staging/wlan-ng/cfg80211.c
index e5d7def1f366..8a862f718d5c 100644
--- a/drivers/staging/wlan-ng/cfg80211.c
+++ b/drivers/staging/wlan-ng/cfg80211.c
@@ -70,7 +70,8 @@ static int prism2_result2err(int prism2_result)
return err;
 }
 
-static int prism2_domibset_uint32(struct wlandevice *wlandev, u32 did, u32 
data)
+static int prism2_domibset_uint32(struct wlandevice *wlandev,
+ u32 did, u32 data)
 {
struct p80211msg_dot11req_mibset msg;
struct p80211item_uint32 *mibitem =
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] staging: android: ashmem: Don't allow range_alloc() to fail.

2019-02-05 Thread Tetsuo Handa
ashmem_pin() is calling range_shrink() without checking whether
range_alloc() succeeded. Since memory allocation fault injection might
force range_alloc() to fail while range_alloc() is called for only once
for one ioctl() request, make range_alloc() not to fail.

Signed-off-by: Tetsuo Handa 
---
 drivers/staging/android/ashmem.c | 17 ++---
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index d40c1d2..a8070a2 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -171,18 +171,14 @@ static inline void lru_del(struct ashmem_range *range)
  * @end:  The ending page (inclusive)
  *
  * This function is protected by ashmem_mutex.
- *
- * Return: 0 if successful, or -ENOMEM if there is an error
  */
-static int range_alloc(struct ashmem_area *asma,
-  struct ashmem_range *prev_range, unsigned int purged,
-  size_t start, size_t end)
+static void range_alloc(struct ashmem_area *asma,
+   struct ashmem_range *prev_range, unsigned int purged,
+   size_t start, size_t end)
 {
struct ashmem_range *range;
 
-   range = kmem_cache_zalloc(ashmem_range_cachep, GFP_KERNEL);
-   if (!range)
-   return -ENOMEM;
+   range = kmem_cache_zalloc(ashmem_range_cachep, GFP_KERNEL | 
__GFP_NOFAIL);
 
range->asma = asma;
range->pgstart = start;
@@ -193,8 +189,6 @@ static int range_alloc(struct ashmem_area *asma,
 
if (range_on_lru(range))
lru_add(range);
-
-   return 0;
 }
 
 /**
@@ -687,7 +681,8 @@ static int ashmem_unpin(struct ashmem_area *asma, size_t 
pgstart, size_t pgend)
}
}
 
-   return range_alloc(asma, range, purged, pgstart, pgend);
+   range_alloc(asma, range, purged, pgstart, pgend);
+   return 0;
 }
 
 /*
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] staging: android: ashmem: Don't call fallocate() with ashmem_mutex held.

2019-02-05 Thread Tetsuo Handa
syzbot is hitting lockdep warnings [1][2][3]. This patch tries to fix
the warning by eliminating ashmem_shrink_scan() => {shmem|vfs}_fallocate()
sequence.

[1] 
https://syzkaller.appspot.com/bug?id=87c399f6fa6955006080b24142e2ce7680295ad4
[2] 
https://syzkaller.appspot.com/bug?id=7ebea492de7521048355fc84210220e1038a7908
[3] 
https://syzkaller.appspot.com/bug?id=e02419c12131c24e2a957ea050c2ab6dcbbc3270

Reported-by: syzbot 
Reported-by: syzbot 
Reported-by: syzbot 
Signed-off-by: Tetsuo Handa 
Cc: sta...@vger.kernel.org
---
 drivers/staging/android/ashmem.c | 25 -
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index 90a8a9f1ac7d..ade8438a827a 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -75,6 +75,9 @@ struct ashmem_range {
 /* LRU list of unpinned pages, protected by ashmem_mutex */
 static LIST_HEAD(ashmem_lru_list);
 
+static atomic_t ashmem_shrink_inflight = ATOMIC_INIT(0);
+static DECLARE_WAIT_QUEUE_HEAD(ashmem_shrink_wait);
+
 /*
  * long lru_count - The count of pages on our LRU list.
  *
@@ -438,7 +441,6 @@ static int ashmem_mmap(struct file *file, struct 
vm_area_struct *vma)
 static unsigned long
 ashmem_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
 {
-   struct ashmem_range *range, *next;
unsigned long freed = 0;
 
/* We might recurse into filesystem code, so bail out if necessary */
@@ -448,21 +450,33 @@ ashmem_shrink_scan(struct shrinker *shrink, struct 
shrink_control *sc)
if (!mutex_trylock(&ashmem_mutex))
return -1;
 
-   list_for_each_entry_safe(range, next, &ashmem_lru_list, lru) {
+   while (!list_empty(&ashmem_lru_list)) {
+   struct ashmem_range *range =
+   list_first_entry(&ashmem_lru_list, typeof(*range), lru);
loff_t start = range->pgstart * PAGE_SIZE;
loff_t end = (range->pgend + 1) * PAGE_SIZE;
+   struct file *f = range->asma->file;
 
-   range->asma->file->f_op->fallocate(range->asma->file,
-   FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
-   start, end - start);
+   get_file(f);
+   atomic_inc(&ashmem_shrink_inflight);
range->purged = ASHMEM_WAS_PURGED;
lru_del(range);
 
freed += range_size(range);
+   mutex_unlock(&ashmem_mutex);
+   f->f_op->fallocate(f,
+  FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
+  start, end - start);
+   fput(f);
+   if (atomic_dec_and_test(&ashmem_shrink_inflight))
+   wake_up_all(&ashmem_shrink_wait);
+   if (!mutex_trylock(&ashmem_mutex))
+   goto out;
if (--sc->nr_to_scan <= 0)
break;
}
mutex_unlock(&ashmem_mutex);
+out:
return freed;
 }
 
@@ -713,6 +727,7 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, 
unsigned long cmd,
return -EFAULT;
 
mutex_lock(&ashmem_mutex);
+   wait_event(ashmem_shrink_wait, !atomic_read(&ashmem_shrink_inflight));
 
if (!asma->file)
goto out_unlock;
-- 
2.17.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 02/12] bnxt: Implement ndo_get_port_parent_id()

2019-02-05 Thread kbuild test robot
Hi Florian,

I love your patch! Yet something to improve:

[auto build test ERROR on net/master]
[also build test ERROR on v5.0-rc4 next-20190205]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Florian-Fainelli/net-Introduce-ndo_get_port_parent_id/20190205-163356
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 8.2.0-11) 8.2.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=8.2.0 make.cross ARCH=sparc64 

All error/warnings (new ones prefixed by >>):

   drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c: In function 
'bnxt_vf_rep_get_port_parent_id':
>> drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c:248:50: error: 'attr' 
>> undeclared (first use in this function); did you mean 'xattr'?
 return bnxt_get_port_parent_id(vf_rep->bp->dev, attr);
 ^~~~
 xattr
   drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c:248:50: note: each undeclared 
identifier is reported only once for each function it appears in
>> drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c:249:1: warning: control 
>> reaches end of non-void function [-Wreturn-type]
}
^

vim +248 drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c

   239  
   240  static int bnxt_vf_rep_get_port_parent_id(struct net_device *dev,
   241struct netdev_phys_item_id 
*ppid)
   242  {
   243  struct bnxt_vf_rep *vf_rep = netdev_priv(dev);
   244  
   245  /* as only PORT_PARENT_ID is supported currently use common code
   246   * between PF and VF-rep for now.
   247   */
 > 248  return bnxt_get_port_parent_id(vf_rep->bp->dev, attr);
 > 249  }
   250  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 09/12] netdevsim: Implement ndo_get_port_parent_id()

2019-02-05 Thread kbuild test robot
Hi Florian,

I love your patch! Yet something to improve:

[auto build test ERROR on net/master]
[also build test ERROR on next-20190205]
[cannot apply to v5.0-rc4]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Florian-Fainelli/net-Introduce-ndo_get_port_parent_id/20190205-163356
config: i386-randconfig-x008-201905 (attached as .config)
compiler: gcc-8 (Debian 8.2.0-14) 8.2.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/net/netdevsim/netdev.c:485:3: error: 'const struct net_device_ops' 
has no member named 'ndo_get_port_paret_id'; did you mean 
'ndo_get_port_parent_id'?
 .ndo_get_port_paret_id = nsim_get_port_parent_id,
  ^
  ndo_get_port_parent_id
>> drivers/net/netdevsim/netdev.c:485:27: error: positional initialization of 
>> field in 'struct' declared with 'designated_init' attribute 
>> [-Werror=designated-init]
 .ndo_get_port_paret_id = nsim_get_port_parent_id,
  ^~~
   drivers/net/netdevsim/netdev.c:485:27: note: (near initialization for 
'nsim_netdev_ops')
   drivers/net/netdevsim/netdev.c:485:27: error: initialization of 'void 
(*)(struct net_device *, struct udp_tunnel_info *)' from incompatible pointer 
type 'int (*)(struct net_device *, struct netdev_phys_item_id *)' 
[-Werror=incompatible-pointer-types]
   drivers/net/netdevsim/netdev.c:485:27: note: (near initialization for 
'nsim_netdev_ops.ndo_udp_tunnel_add')
   cc1: some warnings being treated as errors

vim +485 drivers/net/netdevsim/netdev.c

   464  
   465  static const struct net_device_ops nsim_netdev_ops = {
   466  .ndo_init   = nsim_init,
   467  .ndo_uninit = nsim_uninit,
   468  .ndo_start_xmit = nsim_start_xmit,
   469  .ndo_set_rx_mode= nsim_set_rx_mode,
   470  .ndo_set_mac_address= eth_mac_addr,
   471  .ndo_validate_addr  = eth_validate_addr,
   472  .ndo_change_mtu = nsim_change_mtu,
   473  .ndo_get_stats64= nsim_get_stats64,
   474  .ndo_set_vf_mac = nsim_set_vf_mac,
   475  .ndo_set_vf_vlan= nsim_set_vf_vlan,
   476  .ndo_set_vf_rate= nsim_set_vf_rate,
   477  .ndo_set_vf_spoofchk= nsim_set_vf_spoofchk,
   478  .ndo_set_vf_trust   = nsim_set_vf_trust,
   479  .ndo_get_vf_config  = nsim_get_vf_config,
   480  .ndo_set_vf_link_state  = nsim_set_vf_link_state,
   481  .ndo_set_vf_rss_query_en = nsim_set_vf_rss_query_en,
   482  .ndo_setup_tc   = nsim_setup_tc,
   483  .ndo_set_features   = nsim_set_features,
   484  .ndo_bpf= nsim_bpf,
 > 485  .ndo_get_port_paret_id  = nsim_get_port_parent_id,
   486  };
   487  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 09/12] netdevsim: Implement ndo_get_port_parent_id()

2019-02-05 Thread kbuild test robot
Hi Florian,

I love your patch! Yet something to improve:

[auto build test ERROR on net/master]
[also build test ERROR on next-20190205]
[cannot apply to v5.0-rc4]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Florian-Fainelli/net-Introduce-ndo_get_port_parent_id/20190205-163356
config: x86_64-randconfig-x014-201905 (attached as .config)
compiler: gcc-8 (Debian 8.2.0-14) 8.2.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> drivers/net//netdevsim/netdev.c:485:3: error: 'const struct net_device_ops' 
>> has no member named 'ndo_get_port_paret_id'; did you mean 
>> 'ndo_get_port_parent_id'?
 .ndo_get_port_paret_id = nsim_get_port_parent_id,
  ^
  ndo_get_port_parent_id
>> drivers/net//netdevsim/netdev.c:485:27: error: initialization of 'int 
>> (*)(struct net_device *, int,  struct xdp_frame **, u32)' {aka 'int 
>> (*)(struct net_device *, int,  struct xdp_frame **, unsigned int)'} from 
>> incompatible pointer type 'int (*)(struct net_device *, struct 
>> netdev_phys_item_id *)' [-Werror=incompatible-pointer-types]
 .ndo_get_port_paret_id = nsim_get_port_parent_id,
  ^~~
   drivers/net//netdevsim/netdev.c:485:27: note: (near initialization for 
'nsim_netdev_ops.ndo_xdp_xmit')
   cc1: some warnings being treated as errors

vim +485 drivers/net//netdevsim/netdev.c

   464  
   465  static const struct net_device_ops nsim_netdev_ops = {
   466  .ndo_init   = nsim_init,
   467  .ndo_uninit = nsim_uninit,
   468  .ndo_start_xmit = nsim_start_xmit,
   469  .ndo_set_rx_mode= nsim_set_rx_mode,
   470  .ndo_set_mac_address= eth_mac_addr,
   471  .ndo_validate_addr  = eth_validate_addr,
   472  .ndo_change_mtu = nsim_change_mtu,
   473  .ndo_get_stats64= nsim_get_stats64,
   474  .ndo_set_vf_mac = nsim_set_vf_mac,
   475  .ndo_set_vf_vlan= nsim_set_vf_vlan,
   476  .ndo_set_vf_rate= nsim_set_vf_rate,
   477  .ndo_set_vf_spoofchk= nsim_set_vf_spoofchk,
   478  .ndo_set_vf_trust   = nsim_set_vf_trust,
   479  .ndo_get_vf_config  = nsim_get_vf_config,
   480  .ndo_set_vf_link_state  = nsim_set_vf_link_state,
   481  .ndo_set_vf_rss_query_en = nsim_set_vf_rss_query_en,
   482  .ndo_setup_tc   = nsim_setup_tc,
   483  .ndo_set_features   = nsim_set_features,
   484  .ndo_bpf= nsim_bpf,
 > 485  .ndo_get_port_paret_id  = nsim_get_port_parent_id,
   486  };
   487  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 12/12] net: Get rid of SWITCHDEV_ATTR_ID_PORT_PARENT_ID

2019-02-05 Thread kbuild test robot
Hi Florian,

I love your patch! Yet something to improve:

[auto build test ERROR on net/master]
[also build test ERROR on next-20190205]
[cannot apply to v5.0-rc4]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Florian-Fainelli/net-Introduce-ndo_get_port_parent_id/20190205-163356
config: i386-randconfig-x002-201905 (attached as .config)
compiler: gcc-8 (Debian 8.2.0-14) 8.2.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   net//ipv4/ipmr.c: In function 'vif_add':
>> net//ipv4/ipmr.c:920:2: error: 'attr' undeclared (first use in this 
>> function); did you mean 'xattr'?
 attr.orig_dev = dev;
 ^~~~
 xattr
   net//ipv4/ipmr.c:920:2: note: each undeclared identifier is reported only 
once for each function it appears in

vim +920 net//ipv4/ipmr.c

^1da177e4 Linus Torvalds  2005-04-16  835  
0c12295a7 Patrick McHardy 2010-04-13  836  static int vif_add(struct net 
*net, struct mr_table *mrt,
0c12295a7 Patrick McHardy 2010-04-13  837  struct vifctl *vifc, 
int mrtsock)
^1da177e4 Linus Torvalds  2005-04-16  838  {
ca3b84139 Florian Fainelli2019-02-04  839   struct netdev_phys_item_id ppid 
= { };
f95ad5036 Florian Fainelli2019-02-04  840   const struct net_device_ops 
*ops;
^1da177e4 Linus Torvalds  2005-04-16  841   int vifi = vifc->vifc_vifi;
0c12295a7 Patrick McHardy 2010-04-13  842   struct vif_device *v = 
&mrt->vif_table[vifi];
^1da177e4 Linus Torvalds  2005-04-16  843   struct net_device *dev;
^1da177e4 Linus Torvalds  2005-04-16  844   struct in_device *in_dev;
d607032db Wang Chen   2008-07-14  845   int err;
^1da177e4 Linus Torvalds  2005-04-16  846  
^1da177e4 Linus Torvalds  2005-04-16  847   /* Is vif busy ? */
0c12295a7 Patrick McHardy 2010-04-13  848   if (VIF_EXISTS(mrt, vifi))
^1da177e4 Linus Torvalds  2005-04-16  849   return -EADDRINUSE;
^1da177e4 Linus Torvalds  2005-04-16  850  
^1da177e4 Linus Torvalds  2005-04-16  851   switch (vifc->vifc_flags) {
^1da177e4 Linus Torvalds  2005-04-16  852   case VIFF_REGISTER:
1973a4ea6 Nikolay Aleksandrov 2015-11-26  853   if 
(!ipmr_pimsm_enabled())
c316c629f Nikolay Aleksandrov 2015-11-21  854   return -EINVAL;
c316c629f Nikolay Aleksandrov 2015-11-21  855   /* Special Purpose VIF 
in PIM
^1da177e4 Linus Torvalds  2005-04-16  856* All the packets will 
be sent to the daemon
^1da177e4 Linus Torvalds  2005-04-16  857*/
0c12295a7 Patrick McHardy 2010-04-13  858   if 
(mrt->mroute_reg_vif_num >= 0)
^1da177e4 Linus Torvalds  2005-04-16  859   return 
-EADDRINUSE;
f0ad0860d Patrick McHardy 2010-04-13  860   dev = ipmr_reg_vif(net, 
mrt);
^1da177e4 Linus Torvalds  2005-04-16  861   if (!dev)
^1da177e4 Linus Torvalds  2005-04-16  862   return -ENOBUFS;
d607032db Wang Chen   2008-07-14  863   err = 
dev_set_allmulti(dev, 1);
d607032db Wang Chen   2008-07-14  864   if (err) {
d607032db Wang Chen   2008-07-14  865   
unregister_netdevice(dev);
7dc00c82c Wang Chen   2008-07-14  866   dev_put(dev);
d607032db Wang Chen   2008-07-14  867   return err;
d607032db Wang Chen   2008-07-14  868   }
^1da177e4 Linus Torvalds  2005-04-16  869   break;
^1da177e4 Linus Torvalds  2005-04-16  870   case VIFF_TUNNEL:
4feb88e5c Benjamin Thery  2009-01-22  871   dev = 
ipmr_new_tunnel(net, vifc);
^1da177e4 Linus Torvalds  2005-04-16  872   if (!dev)
^1da177e4 Linus Torvalds  2005-04-16  873   return -ENOBUFS;
d607032db Wang Chen   2008-07-14  874   err = 
dev_set_allmulti(dev, 1);
d607032db Wang Chen   2008-07-14  875   if (err) {
d607032db Wang Chen   2008-07-14  876   
ipmr_del_tunnel(dev, vifc);
7dc00c82c Wang Chen   2008-07-14  877   dev_put(dev);
d607032db Wang Chen   2008-07-14  878   return err;
d607032db Wang Chen   2008-07-14  879   }
^1da177e4 Linus Torvalds  2005-04-16  880   break;
ee5e81f00 Ilia K  2009-09-16  881   case VIFF_USE_IFINDEX:
^1da177e4 Linus Torvalds  2005-04-16  882   case 0:
ee5e81f00 Ilia K  2009-09-16  883   if (vifc->vifc_flags == 
VIFF_USE_IFINDEX) {
ee5e81f00 Ilia K  2009-09-16  884   dev = 
dev_get_by_index(net, vifc->vifc_lcl_ifindex);
51456b291 Ian Morris  2015-04-03  885   if (dev && 
!__in_dev_get_rtnl(dev)) {
ee5e81f00 Ilia K  

Re: [PATCH] Staging: rtl8723bs: remove some dead code

2019-02-05 Thread Hans de Goede

Hi,

On 04-02-19 19:24, Dan Carpenter wrote:

"psecnetwork" is the address of &psecuritypriv->sec_bss.  Since
->sec_bss isn't the first member of the struct that means that
"psecnetwork" can't be NULL.

We can just remove this dead code.

Signed-off-by: Dan Carpenter 


Thanks, LGTM:

Reviewed-by: Hans de Goede 

Regards,

Hans




---
  drivers/staging/rtl8723bs/core/rtw_cmd.c | 8 
  1 file changed, 8 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c 
b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index ea2c187e56bd..91520ca3bbad 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -835,14 +835,6 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct 
wlan_network *pnetwork)
}
  
  	psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss;

-   if (psecnetwork == NULL) {
-   kfree(pcmd);
-   res = _FAIL;
-
-   RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("rtw_joinbss_cmd 
:psecnetwork == NULL!!!\n"));
-
-   goto exit;
-   }
  
  	memset(psecnetwork, 0, t_len);
  


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 12/12] net: Get rid of SWITCHDEV_ATTR_ID_PORT_PARENT_ID

2019-02-05 Thread Ido Schimmel
On Mon, Feb 04, 2019 at 03:36:33PM -0800, Florian Fainelli wrote:
> Now that we have a dedicated NDO for getting a port's parent ID, get rid
> of SWITCHDEV_ATTR_ID_PORT_PARENT_ID and convert all callers to use the
> NDO exclusively. This is a preliminary change to getting rid of
> switchdev_ops eventually.
> 
> Signed-off-by: Florian Fainelli 
> ---
>  include/net/switchdev.h   |  2 --
>  net/bridge/br_switchdev.c | 11 +++
>  net/core/net-sysfs.c  | 14 +++---
>  net/core/rtnetlink.c  | 16 
>  net/ipv4/ipmr.c   | 14 --
>  net/switchdev/switchdev.c | 20 +---
>  6 files changed, 23 insertions(+), 54 deletions(-)
> 
> diff --git a/include/net/switchdev.h b/include/net/switchdev.h
> index 63843ae5dc81..e1a5e8bc24b8 100644
> --- a/include/net/switchdev.h
> +++ b/include/net/switchdev.h
> @@ -43,7 +43,6 @@ static inline bool switchdev_trans_ph_commit(struct 
> switchdev_trans *trans)
>  
>  enum switchdev_attr_id {
>   SWITCHDEV_ATTR_ID_UNDEFINED,
> - SWITCHDEV_ATTR_ID_PORT_PARENT_ID,
>   SWITCHDEV_ATTR_ID_PORT_STP_STATE,
>   SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS,
>   SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT,
> @@ -61,7 +60,6 @@ struct switchdev_attr {
>   void *complete_priv;
>   void (*complete)(struct net_device *dev, int err, void *priv);
>   union {
> - struct netdev_phys_item_id ppid;/* PORT_PARENT_ID */
>   u8 stp_state;   /* PORT_STP_STATE */
>   unsigned long brport_flags; /* PORT_BRIDGE_FLAGS */
>   unsigned long brport_flags_support; /* 
> PORT_BRIDGE_FLAGS_SUPPORT */
> diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
> index 501a4221220a..620fd645f6f1 100644
> --- a/net/bridge/br_switchdev.c
> +++ b/net/bridge/br_switchdev.c
> @@ -24,18 +24,13 @@ static int br_switchdev_mark_get(struct net_bridge *br, 
> struct net_device *dev)
>  int nbp_switchdev_mark_set(struct net_bridge_port *p)
>  {
>   const struct net_device_ops *ops = p->dev->netdev_ops;
> - struct switchdev_attr attr = {
> - .orig_dev = p->dev,
> - .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID,
> - };
> - int err;
> + struct netdev_phys_item_id ppid = { };
> + int err = -EOPNOTSUPP;
>  
>   ASSERT_RTNL();
>  
>   if (ops->ndo_get_port_parent_id)
> - err = ops->ndo_get_port_parent_id(p->dev, &attr.u.ppid);
> - else
> - err = switchdev_port_attr_get(p->dev, &attr);
> + err = ops->ndo_get_port_parent_id(p->dev, &ppid);
>   if (err) {
>   if (err == -EOPNOTSUPP)
>   return 0;
> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> index cc05e8b72657..1d2d76930afd 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -12,7 +12,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> @@ -502,19 +501,12 @@ static ssize_t phys_switch_id_show(struct device *dev,
>   return restart_syscall();
>  
>   if (dev_isalive(netdev)) {
> - struct switchdev_attr attr = {
> - .orig_dev = netdev,
> - .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID,
> - .flags = SWITCHDEV_F_NO_RECURSE,

Florian, note this flag. We should not return the parent id in case this
is called for a stacked device. Maybe extend the ndo with a new
parameter called 'recurse' ? Or you can check here if device has lower
devices and bail.

> - };
> + struct netdev_phys_item_id ppid = { };
>  
>   if (ops->ndo_get_port_parent_id)
> - ret = ops->ndo_get_port_parent_id(netdev, &attr.u.ppid);
> - else
> - ret = switchdev_port_attr_get(netdev, &attr);
> + ret = ops->ndo_get_port_parent_id(netdev, &ppid);
>   if (!ret)
> - ret = sprintf(buf, "%*phN\n", attr.u.ppid.id_len,
> -   attr.u.ppid.id);
> + ret = sprintf(buf, "%*phN\n", ppid.id_len, ppid.id);
>   }
>   rtnl_unlock();
>  
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index ed8564eb97c8..27bccf68538e 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -46,7 +46,6 @@
>  
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> @@ -1147,25 +1146,18 @@ static int rtnl_phys_port_name_fill(struct sk_buff 
> *skb, struct net_device *dev)
>  static int rtnl_phys_switch_id_fill(struct sk_buff *skb, struct net_device 
> *dev)
>  {
>   const struct net_device_ops *ops = dev->netdev_ops;
> - int err;
> - struct switchdev_attr attr = {
> - .orig_dev = dev,
> - .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID,
> - .flags = SWITCHDEV_F_NO_RECURSE,

Same here.

> - };
> + struct netd