[PATCH] Documentation/isdn: check and fix dead links ...

2018-03-23 Thread Sanjeev Gupta
and switch to https where possible.

All links have been eyeballed to verify that the domains have
not changed, etc.

Signed-off-by: Sanjeev Gupta 
---
 Documentation/isdn/INTERFACE.CAPI |  2 +-
 Documentation/isdn/README |  4 ++--
 Documentation/isdn/README.FAQ |  4 ++--
 Documentation/isdn/README.gigaset | 16 +---
 4 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/Documentation/isdn/INTERFACE.CAPI 
b/Documentation/isdn/INTERFACE.CAPI
index 1688b5a1fd77..021aa9cf139d 100644
--- a/Documentation/isdn/INTERFACE.CAPI
+++ b/Documentation/isdn/INTERFACE.CAPI
@@ -18,7 +18,7 @@ corresponding hardware driver. Kernel CAPI then forwards CAPI 
messages in both
 directions between the application and the hardware driver.
 
 Format and semantics of CAPI messages are specified in the CAPI 2.0 standard.
-This standard is freely available from http://www.capi.org.
+This standard is freely available from https://www.capi.org.
 
 
 2. Driver and Device Registration
diff --git a/Documentation/isdn/README b/Documentation/isdn/README
index 32d4e80c2c03..74bd2bdb455b 100644
--- a/Documentation/isdn/README
+++ b/Documentation/isdn/README
@@ -33,10 +33,10 @@ README for the ISDN-subsystem
  de.alt.comm.isdn4linux
 
   There is also a well maintained FAQ in English available at
- http://www.mhessler.de/i4lfaq/
+ https://www.mhessler.de/i4lfaq/
   It can be viewed online, or downloaded in sgml/text/html format.
   The FAQ can also be viewed online at
- http://www.isdn4linux.de/faq/
+ https://www.isdn4linux.de/faq/i4lfaq.html
   or downloaded from
  ftp://ftp.isdn4linux.de/pub/isdn4linux/FAQ/
 
diff --git a/Documentation/isdn/README.FAQ b/Documentation/isdn/README.FAQ
index 356f7944641d..e5dd1addacdd 100644
--- a/Documentation/isdn/README.FAQ
+++ b/Documentation/isdn/README.FAQ
@@ -8,9 +8,9 @@ You find it in:
 
 In case you just want to see the FAQ online, or download the newest version,
 you can have a look at my website:
-http://www.mhessler.de/i4lfaq/ (view + download)
+https://www.mhessler.de/i4lfaq/ (view + download)
 or:
-http://www.isdn4linux.de/faq/ (view)
+https://www.isdn4linux.de/faq/4lfaq.html (view)
 
 As the extension tells, the FAQ is in SGML format, and you can convert it
 into text/html/... format by using the sgml2txt/sgml2html/... tools.
diff --git a/Documentation/isdn/README.gigaset 
b/Documentation/isdn/README.gigaset
index 7534c6039adc..9b1ce277ca3d 100644
--- a/Documentation/isdn/README.gigaset
+++ b/Documentation/isdn/README.gigaset
@@ -29,8 +29,9 @@ GigaSet 307x Device Driver
 T-Com Sinus 721 data
 Chicago 390 USB (KPN)
 
- See also http://www.erbze.info/sinus_gigaset.htm and
-  http://gigaset307x.sourceforge.net/
+ See also http://www.erbze.info/sinus_gigaset.htm
+   (archived at 
https://web.archive.org/web/20100717020421/http://www.erbze.info:80/sinus_gigaset.htm
 ) and
+   http://gigaset307x.sourceforge.net/
 
  We had also reports from users of Gigaset M105 who could use the drivers
  with SX 100 and CX 100 ISDN bases (only in unimodem mode, see section 
2.5.)
@@ -52,7 +53,7 @@ GigaSet 307x Device Driver
  to use CAPI 2.0 or ISDN4Linux for ISDN connections (voice or data).
 
  There are some user space tools available at
- http://sourceforge.net/projects/gigaset307x/
+ https://sourceforge.net/projects/gigaset307x/
  which provide access to additional device specific functions like SMS,
  phonebook or call journal.
 
@@ -202,7 +203,7 @@ GigaSet 307x Device Driver
  You can use some configuration tool of your distribution to configure this
  "modem" or configure pppd/wvdial manually. There are some example ppp
  configuration files and chat scripts in the gigaset-VERSION/ppp directory
- in the driver packages from http://sourceforge.net/projects/gigaset307x/.
+ in the driver packages from https://sourceforge.net/projects/gigaset307x/.
  Please note that the USB drivers are not able to change the state of the
  control lines. This means you must use "Stupid Mode" if you are using
  wvdial or you should use the nocrtscts option of pppd.
@@ -361,7 +362,7 @@ GigaSet 307x Device Driver
  ---
  If you can't solve problems with the driver on your own, feel free to
  use one of the forums, bug trackers, or mailing lists on
- http://sourceforge.net/projects/gigaset307x
+ https://sourceforge.net/projects/gigaset307x
  or write an electronic mail to the maintainers.
 
  Try to provide as much information as possible, such as
@@ -391,11 +392,12 @@ GigaSet 307x Device Driver
 4.   Links, other software
  -
  - Sourceforge project developing this driver and associated tools
- http://sourceforge.net/projects/gigaset307x
+ https://sourceforge.net/projects/gigaset307x
  - Yahoo! Group on the Siemens Gigaset family of devices
- 

[PATCH net-next] ptp: Fix documentation to match code.

2018-03-23 Thread Richard Cochran
Ever since commit 3a06c7ac24f9 ("posix-clocks: Remove interval timer
facility and mmap/fasync callbacks") the possibility of PHC based
posix timers has been removed.  In addition it will probably never
make sense to implement this functionality.

This patch removes the misleading text which seems to suggest that
posix timers for PHC devices will ever be a thing.

Signed-off-by: Richard Cochran 
---
 Documentation/ptp/ptp.txt | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/Documentation/ptp/ptp.txt b/Documentation/ptp/ptp.txt
index ae8fef86b832..11e904ee073f 100644
--- a/Documentation/ptp/ptp.txt
+++ b/Documentation/ptp/ptp.txt
@@ -18,7 +18,6 @@
 - Adjust clock frequency
 
   + Ancillary clock features
-- One short or periodic alarms, with signal delivery to user program
 - Time stamp external events
 - Period output signals configurable from user space
 - Synchronization of the Linux system time via the PPS subsystem
@@ -48,9 +47,7 @@
User space programs may control the clock using standardized
ioctls. A program may query, enable, configure, and disable the
ancillary clock features. User space can receive time stamped
-   events via blocking read() and poll(). One shot and periodic
-   signals may be configured via the POSIX timer_settime() system
-   call.
+   events via blocking read() and poll().
 
 ** Writing clock drivers
 
-- 
2.11.0



Re: [PATCH v6 6/6] bnxt_en: Eliminate duplicate barriers on weakly-ordered archs

2018-03-23 Thread Sinan Kaya
On 3/23/2018 6:36 PM, Michael Chan wrote:
>> +   mmiowb();
> Sorry for the late review.  mmiowb() is not required here because we
> are in NAPI context, so only one CPU will be updating this doorbell.
> 
> Other than that, it looks good.
> 

OK, I'll fix this on the next version.

-- 
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm 
Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux 
Foundation Collaborative Project.


Re: [PATCH RFC net-next 7/7] netdevsim: Add simple FIB resource controller via devlink

2018-03-23 Thread Jakub Kicinski
On Thu, 22 Mar 2018 15:57:57 -0700, David Ahern wrote:
> From: David Ahern 
> 
> Add devlink support to netdevsim and use it to implement a simple,
> profile based resource controller. Only one controller is needed
> per namespace, so the first netdevsim netdevice in a namespace
> registers with devlink. If that device is deleted, the resource
> settings are deleted.

FWIW some nits from me blow.

> diff --git a/drivers/net/netdevsim/Makefile b/drivers/net/netdevsim/Makefile
> index 09388c06171d..449b2a1a1800 100644
> --- a/drivers/net/netdevsim/Makefile
> +++ b/drivers/net/netdevsim/Makefile
> @@ -9,3 +9,7 @@ ifeq ($(CONFIG_BPF_SYSCALL),y)
>  netdevsim-objs += \
>   bpf.o
>  endif
> +
> +ifneq ($(CONFIG_NET_DEVLINK),)

Hm.  Don't you need MAY_USE_DEVLINK dependency perhaps?

> +netdevsim-objs += devlink.o fib.o
> +endif
> diff --git a/drivers/net/netdevsim/devlink.c b/drivers/net/netdevsim/devlink.c
> new file mode 100644
> index ..d10558e1b022
> --- /dev/null
> +++ b/drivers/net/netdevsim/devlink.c
 
> +static int devlink_resources_register(struct devlink *devlink)
> +{
> + struct devlink_resource_size_params params = {
> + .size_max = (u64)-1,
> + .size_granularity = 1,
> + .unit = DEVLINK_RESOURCE_UNIT_ENTRY
> + };
> + struct net *net = devlink_net(devlink);
> + int err;
> + u64 n;
> +
> + /* Resources for IPv4 */
> + err = devlink_resource_register(devlink, "IPv4", (u64)-1,
> + NSIM_RESOURCE_IPV4,
> + DEVLINK_RESOURCE_ID_PARENT_TOP,
> + , NULL);
> + if (err) {
> + pr_err("Failed to register IPv4 top resource\n");
> + goto out;

nit: why goto out here and return err everywhere else?  If I was to
 choose I'd rather see returns.  goto X; X: return; is less
 obviously correct IMHO.  Besides labels should be called by the
 action they perform/undo, so goto err_return? :S

> + }
> +
> + n = nsim_fib_get_val(net, NSIM_RESOURCE_IPV4_FIB, true);
> + err = devlink_resource_register(devlink, "fib", n,
> + NSIM_RESOURCE_IPV4_FIB,
> + NSIM_RESOURCE_IPV4,
> + , _ipv4_fib_res_ops);
> + if (err) {
> + pr_err("Failed to register IPv4 FIB resource\n");
> + return err;
> + }
> +
> + n = nsim_fib_get_val(net, NSIM_RESOURCE_IPV4_FIB_RULES, true);
> + err = devlink_resource_register(devlink, "fib-rules", n,
> + NSIM_RESOURCE_IPV4_FIB_RULES,
> + NSIM_RESOURCE_IPV4,
> + , _ipv4_fib_rules_res_ops);
> + if (err) {
> + pr_err("Failed to register IPv4 FIB rules resource\n");
> + return err;
> + }
> +
> + /* Resources for IPv6 */
> + err = devlink_resource_register(devlink, "IPv6", (u64)-1,
> + NSIM_RESOURCE_IPV6,
> + DEVLINK_RESOURCE_ID_PARENT_TOP,
> + , NULL);
> + if (err) {
> + pr_err("Failed to register IPv6 top resource\n");
> + goto out;
> + }
> +
> + n = nsim_fib_get_val(net, NSIM_RESOURCE_IPV6_FIB, true);
> + err = devlink_resource_register(devlink, "fib", n,
> + NSIM_RESOURCE_IPV6_FIB,
> + NSIM_RESOURCE_IPV6,
> + , _ipv6_fib_res_ops);
> + if (err) {
> + pr_err("Failed to register IPv6 FIB resource\n");
> + return err;
> + }
> +
> + n = nsim_fib_get_val(net, NSIM_RESOURCE_IPV6_FIB_RULES, true);
> + err = devlink_resource_register(devlink, "fib-rules", n,
> + NSIM_RESOURCE_IPV6_FIB_RULES,
> + NSIM_RESOURCE_IPV6,
> + , _ipv6_fib_rules_res_ops);
> + if (err) {
> + pr_err("Failed to register IPv6 FIB rules resource\n");
> + return err;
> + }
> +out:
> + return err;
> +}

> +void nsim_devlink_teardown(struct netdevsim *ns)
> +{
> + if (ns->devlink) {
> + struct net *net = dev_net(ns->netdev);
> + bool *reg_devlink = net_generic(net, nsim_devlink_id);

nit: reverse xmas tree

> + devlink_unregister(ns->devlink);
> + devlink_free(ns->devlink);
> + ns->devlink = NULL;
> +
> + nsim_devlink_net_reset(net);
> + *reg_devlink = true;
> + }
> +}

> diff --git a/drivers/net/netdevsim/fib.c b/drivers/net/netdevsim/fib.c
> new file mode 100644
> index ..b77dcafc7158
> --- /dev/null
> +++ b/drivers/net/netdevsim/fib.c

> +static int nsim_fib_event_nb(struct 

RE: [Intel-wired-lan] [next-queue PATCH v5 7/9] igb: Add MAC address support for ethtool nftuple filters

2018-03-23 Thread Brown, Aaron F
> From: Intel-wired-lan [mailto:intel-wired-lan-boun...@osuosl.org] On
> Behalf Of Vinicius Costa Gomes
> Sent: Wednesday, March 21, 2018 5:34 PM
> To: intel-wired-...@lists.osuosl.org
> Cc: netdev@vger.kernel.org; Sanchez-Palencia, Jesus  palen...@intel.com>
> Subject: [Intel-wired-lan] [next-queue PATCH v5 7/9] igb: Add MAC address
> support for ethtool nftuple filters
> 
> This adds the capability of configuring the queue steering of arriving
> packets based on their source and destination MAC addresses.
> 
> In practical terms this adds support for the following use cases,
> characterized by these examples:
> 
> $ ethtool -N eth0 flow-type ether dst aa:aa:aa:aa:aa:aa action 0
> (this will direct packets with destination address "aa:aa:aa:aa:aa:aa"
> to the RX queue 0)
> 
> $ ethtool -N eth0 flow-type ether src 44:44:44:44:44:44 action 3
> (this will direct packets with source address "44:44:44:44:44:44" to
> the RX queue 3)
> 
> Signed-off-by: Vinicius Costa Gomes 
> ---
>  drivers/net/ethernet/intel/igb/igb_ethtool.c | 35
> 
>  1 file changed, 31 insertions(+), 4 deletions(-)

Maybe not "this" patch, but this is the one that enables the ethtool commands, 
so replying here.
The filters do not seem to take effect with this version (v5) of the series.  
The commands are accepted for i210 and rejected with unsupported messages for 
the other adapters (as desired) and an ethtool -n shows the filter, however, 
with either the src or dst filter set I can run traffic (netperf) that should 
be caught by the filter and rather than being directed to the single queue it 
is spread across queues as would be expected without the filter set.

The test system still has a kernel / driver with the v4 series of this patch 
set and the exact same filter commands / system setup does filter the traffic 
to the specified rx queue with the v4 series.


Re: [patch net-next RFC 10/12] nfp: flower: create port for flower vnic

2018-03-23 Thread Jakub Kicinski
On Fri, 23 Mar 2018 07:29:41 +0100, Jiri Pirko wrote:
> >This will associate the PF netdev with physical port, incl. all ethtool
> >information.  Im not sure we want to do that.  phy_repr carries this
> >functionality.  
> 
> I was not sure originally what this port is. Okay, what I would like to
> see is another port flavour for "pf" and "vf". I guess that since the pf
> has the same pci address, it would fall under the same devlink instance.
> For vfs, which have each separate pci address, I would like to create
> devlink instance for each and associate with one devlink port flavour
> "vf".

Why do we need a devlink instance and phys port name for vfs?  Just
wondering..  It seems they should be covered by having different bus
address.  For full coverage of all netdevs?


[PATCH net-next 4/5] net: hns3: fix for not initializing VF rss_hash_key problem

2018-03-23 Thread Peng Li
From: Fuyun Liang 

Default rss_hash_key value should be given to all vports. But just the
PF rss_hash_key has the default value here. This patch adds rss_hash_key
Initialization for all vports.

Signed-off-by: Fuyun Liang 
Signed-off-by: Peng Li 
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index bede411..ce093c3 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -3466,8 +3466,6 @@ static void hclge_rss_init_cfg(struct hclge_dev *hdev)
struct hclge_vport *vport = hdev->vport;
int i;
 
-   netdev_rss_key_fill(vport->rss_hash_key, HCLGE_RSS_KEY_SIZE);
-
for (i = 0; i < hdev->num_vmdq_vport + 1; i++) {
vport[i].rss_tuple_sets.ipv4_tcp_en =
HCLGE_RSS_INPUT_TUPLE_OTHER;
@@ -3487,6 +3485,8 @@ static void hclge_rss_init_cfg(struct hclge_dev *hdev)
HCLGE_RSS_INPUT_TUPLE_OTHER;
 
vport[i].rss_algo = HCLGE_RSS_HASH_ALGO_TOEPLITZ;
+
+   netdev_rss_key_fill(vport[i].rss_hash_key, HCLGE_RSS_KEY_SIZE);
}
 
hclge_rss_indir_init_cfg(hdev);
-- 
2.9.3



[PATCH net-next 1/5] net: hns3: fix for returning wrong value problem in hns3_get_rss_key_size

2018-03-23 Thread Peng Li
From: Fuyun Liang 

The return type of hns3_get_rss_key_size is u32. But a negative value is
returned. This patch fixes it by replacing the negative value with zero.

Signed-off-by: Fuyun Liang 
Signed-off-by: Peng Li 
---
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 9d07116..ac523c9 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -638,7 +638,7 @@ static u32 hns3_get_rss_key_size(struct net_device *netdev)
 
if (!h->ae_algo || !h->ae_algo->ops ||
!h->ae_algo->ops->get_rss_key_size)
-   return -EOPNOTSUPP;
+   return 0;
 
return h->ae_algo->ops->get_rss_key_size(h);
 }
-- 
2.9.3



[PATCH net-next 0/5] fix some bugs for HNS3

2018-03-23 Thread Peng Li
This patchset fixes some bugs for HNS3 driver:
[Patch 1/5 - 2/5] fix 2 return vlaue issues.
[Patch 3/5 - 4/5] fix 2 comments reported by code review.
[Ptach 5/5] avoid sending message to IMP because IMP will not
handle any message when it is resetting.

Fuyun Liang (4):
  net: hns3: fix for returning wrong value problem in
hns3_get_rss_key_size
  net: hns3: fix for returning wrong value problem in
hns3_get_rss_indir_size
  net: hns3: fix for the wrong shift problem in hns3_set_txbd_baseinfo
  net: hns3: fix for not initializing VF rss_hash_key problem

Peng Li (1):
  net: hns3: never send command queue message to IMP when reset

 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c|  2 +-
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c |  4 ++--
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c| 27 --
 .../ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c|  6 +
 4 files changed, 29 insertions(+), 10 deletions(-)

-- 
2.9.3



[PATCH net-next 2/5] net: hns3: fix for returning wrong value problem in hns3_get_rss_indir_size

2018-03-23 Thread Peng Li
From: Fuyun Liang 

The return type of hns3_get_rss_indir_size is u32. But a negative value is
returned. This patch fixes it by replacing the negative value with zero.

Signed-off-by: Fuyun Liang 
Signed-off-by: Peng Li 
---
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index ac523c9..eb3c34f 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -649,7 +649,7 @@ static u32 hns3_get_rss_indir_size(struct net_device 
*netdev)
 
if (!h->ae_algo || !h->ae_algo->ops ||
!h->ae_algo->ops->get_rss_indir_size)
-   return -EOPNOTSUPP;
+   return 0;
 
return h->ae_algo->ops->get_rss_indir_size(h);
 }
-- 
2.9.3



[PATCH net-next 5/5] net: hns3: never send command queue message to IMP when reset

2018-03-23 Thread Peng Li
IMP will not handle and command queue message any more when it is
in core/global, driver should not send command queue message to
IMP until reinitialize the NIC HW.

This patch checks the status and avoid the message sent to IMP when
reset.

Signed-off-by: Peng Li 
---
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c| 23 +-
 .../ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c|  6 ++
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index ce093c3..2066dd7 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -3584,6 +3584,9 @@ static int hclge_unmap_ring_frm_vector(struct 
hnae3_handle *handle,
struct hclge_dev *hdev = vport->back;
int vector_id, ret;
 
+   if (test_bit(HCLGE_STATE_RST_HANDLING, >state))
+   return 0;
+
vector_id = hclge_get_vector_index(hdev, vector);
if (vector_id < 0) {
dev_err(>pdev->dev,
@@ -3781,13 +3784,16 @@ static int hclge_ae_start(struct hnae3_handle *handle)
clear_bit(HCLGE_STATE_DOWN, >state);
mod_timer(>service_timer, jiffies + HZ);
 
+   /* reset tqp stats */
+   hclge_reset_tqp_stats(handle);
+
+   if (test_bit(HCLGE_STATE_RST_HANDLING, >state))
+   return 0;
+
ret = hclge_mac_start_phy(hdev);
if (ret)
return ret;
 
-   /* reset tqp stats */
-   hclge_reset_tqp_stats(handle);
-
return 0;
 }
 
@@ -3797,6 +3803,12 @@ static void hclge_ae_stop(struct hnae3_handle *handle)
struct hclge_dev *hdev = vport->back;
int i;
 
+   del_timer_sync(>service_timer);
+   cancel_work_sync(>service_task);
+
+   if (test_bit(HCLGE_STATE_RST_HANDLING, >state))
+   return;
+
for (i = 0; i < vport->alloc_tqps; i++)
hclge_tqp_enable(hdev, i, 0, false);
 
@@ -3807,8 +3819,6 @@ static void hclge_ae_stop(struct hnae3_handle *handle)
 
/* reset tqp stats */
hclge_reset_tqp_stats(handle);
-   del_timer_sync(>service_timer);
-   cancel_work_sync(>service_task);
hclge_update_link_status(hdev);
 }
 
@@ -4940,6 +4950,9 @@ void hclge_reset_tqp(struct hnae3_handle *handle, u16 
queue_id)
u16 queue_gid;
int ret;
 
+   if (test_bit(HCLGE_STATE_RST_HANDLING, >state))
+   return;
+
queue_gid = hclge_covert_handle_qid_global(handle, queue_id);
 
ret = hclge_tqp_enable(hdev, queue_id, 0, false);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
index c1dea3a..682c2d6 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
@@ -60,6 +60,9 @@ static int hclge_mdio_write(struct mii_bus *bus, int phyid, 
int regnum,
struct hclge_desc desc;
int ret;
 
+   if (test_bit(HCLGE_STATE_RST_HANDLING, >state))
+   return 0;
+
hclge_cmd_setup_basic_desc(, HCLGE_OPC_MDIO_CONFIG, false);
 
mdio_cmd = (struct hclge_mdio_cfg_cmd *)desc.data;
@@ -95,6 +98,9 @@ static int hclge_mdio_read(struct mii_bus *bus, int phyid, 
int regnum)
struct hclge_desc desc;
int ret;
 
+   if (test_bit(HCLGE_STATE_RST_HANDLING, >state))
+   return 0;
+
hclge_cmd_setup_basic_desc(, HCLGE_OPC_MDIO_CONFIG, true);
 
mdio_cmd = (struct hclge_mdio_cfg_cmd *)desc.data;
-- 
2.9.3



[PATCH net-next 3/5] net: hns3: fix for the wrong shift problem in hns3_set_txbd_baseinfo

2018-03-23 Thread Peng Li
From: Fuyun Liang 

Third parameter of hnae_set_field is shift, But a mask is given. This
patch fixes it by replacing HNS3_TXD_BDTYPE_M with HNS3_TXD_BDTYPE_S.

Signed-off-by: Fuyun Liang 
Signed-off-by: Peng Li 
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 40a3eb7..a31b4ad 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -764,7 +764,7 @@ static void hns3_set_txbd_baseinfo(u16 
*bdtp_fe_sc_vld_ra_ri, int frag_end)
 {
/* Config bd buffer end */
hnae_set_field(*bdtp_fe_sc_vld_ra_ri, HNS3_TXD_BDTYPE_M,
-  HNS3_TXD_BDTYPE_M, 0);
+  HNS3_TXD_BDTYPE_S, 0);
hnae_set_bit(*bdtp_fe_sc_vld_ra_ri, HNS3_TXD_FE_B, !!frag_end);
hnae_set_bit(*bdtp_fe_sc_vld_ra_ri, HNS3_TXD_VLD_B, 1);
hnae_set_field(*bdtp_fe_sc_vld_ra_ri, HNS3_TXD_SC_M, HNS3_TXD_SC_S, 0);
-- 
2.9.3



[PATCH bpf] nfp: bpf: fix check of program max insn count

2018-03-23 Thread Jakub Kicinski
NFP program allocation length is in bytes and NFP program length
is in instructions, fix the comparison of the two.

Fixes: 9314c442d7dd ("nfp: bpf: move translation prepare to offload.c")
Signed-off-by: Jakub Kicinski 
Reviewed-by: Jiong Wang 
---
 drivers/net/ethernet/netronome/nfp/bpf/jit.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/netronome/nfp/bpf/jit.c 
b/drivers/net/ethernet/netronome/nfp/bpf/jit.c
index 56451edf01c2..ecd7c33baf3c 100644
--- a/drivers/net/ethernet/netronome/nfp/bpf/jit.c
+++ b/drivers/net/ethernet/netronome/nfp/bpf/jit.c
@@ -74,7 +74,9 @@ nfp_meta_has_prev(struct nfp_prog *nfp_prog, struct 
nfp_insn_meta *meta)
 
 static void nfp_prog_push(struct nfp_prog *nfp_prog, u64 insn)
 {
-   if (nfp_prog->__prog_alloc_len == nfp_prog->prog_len) {
+   if (nfp_prog->__prog_alloc_len / sizeof(u64) == nfp_prog->prog_len) {
+   pr_warn("instruction limit reached (%u NFP instructions)\n",
+   nfp_prog->prog_len);
nfp_prog->error = -ENOSPC;
return;
}
@@ -2463,6 +2465,8 @@ static int nfp_translate(struct nfp_prog *nfp_prog)
err = cb(nfp_prog, meta);
if (err)
return err;
+   if (nfp_prog->error)
+   return nfp_prog->error;
 
nfp_prog->n_translated++;
}
-- 
2.16.2



[PATCH bpf] tools: bpftool: don't use hex numbers in JSON output

2018-03-23 Thread Jakub Kicinski
JSON does not accept hex numbers with 0x prefix.  Simply print
as decimal numbers, JSON should be primarily machine-readable.

Signed-off-by: Jakub Kicinski 
Reviewed-by: Quentin Monnet 
Fixes: 831a0aafe5c3 ("tools: bpftool: add JSON output for `bpftool map *` 
commands")
---
 tools/bpf/bpftool/map.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index f95fa67bb498..f509c86faede 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -428,7 +428,7 @@ static int show_map_close_json(int fd, struct bpf_map_info 
*info)
jsonw_string_field(json_wtr, "name", info->name);
 
jsonw_name(json_wtr, "flags");
-   jsonw_printf(json_wtr, "%#x", info->map_flags);
+   jsonw_printf(json_wtr, "%d", info->map_flags);
 
print_dev_json(info->ifindex, info->netns_dev, info->netns_ino);
 
-- 
2.16.2



[PATCH net] nfp: use full 40 bits of the NSP buffer address

2018-03-23 Thread Jakub Kicinski
From: Dirk van der Merwe 

The NSP default buffer is a piece of NFP memory where additional
command data can be placed.  Its format has been copied from
host buffer, but the PCIe selection bits do not make sense in
this case.  If those get masked out from a NFP address - writes
to random place in the chip memory may be issued and crash the
device.

This has never been an issue because the buffer used to be
allocated in memory with less-than-38-bit-long address but that
is about to change.

Signed-off-by: Dirk van der Merwe 
Signed-off-by: Jakub Kicinski 
---
 drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c 
b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c
index 39abac678b71..b54ab02f5b33 100644
--- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c
+++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c
@@ -71,8 +71,7 @@
 /* CPP address to retrieve the data from */
 #define NSP_BUFFER 0x10
 #define   NSP_BUFFER_CPP   GENMASK_ULL(63, 40)
-#define   NSP_BUFFER_PCIE  GENMASK_ULL(39, 38)
-#define   NSP_BUFFER_ADDRESS   GENMASK_ULL(37, 0)
+#define   NSP_BUFFER_ADDRESS   GENMASK_ULL(39, 0)
 
 #define NSP_DFLT_BUFFER0x18
 
-- 
2.16.2



Re: [PATCH v5 bpf-next 00/10] bpf, tracing: introduce bpf raw tracepoints

2018-03-23 Thread Alexei Starovoitov

On 3/23/18 7:30 PM, Alexei Starovoitov wrote:

From: Alexei Starovoitov 

v4->v5:
- adopted Daniel's fancy REPEAT macro in bpf_trace.c in patch 7


Daniel,
if you don't mind I'd like to land the patch set in this shape
and you can follow up with additional macro magic,
since I don't understand how the UNPACK part of it works.
It sort of looks unnecessary, but if remove it then (,) doesn't
get 'unpacked' into single comma.
Yet if __DL_COM is defined as , without ()
then nothing works. My brain is hurting.



Re: [PATCH v7 0/7] netdev: intel: Eliminate duplicate barriers on weakly-ordered archs

2018-03-23 Thread okaya

On 2018-03-23 19:58, Jeff Kirsher wrote:

On Fri, 2018-03-23 at 14:53 -0700, Alexander Duyck wrote:

On Fri, Mar 23, 2018 at 11:52 AM, Sinan Kaya 
wrote:
> Code includes wmb() followed by writel() in multiple places. writel()
> already has a barrier on some architectures like arm64.
>
> This ends up CPU observing two barriers back to back before executing
> the
> register write.
>
> Since code already has an explicit barrier call, changing writel() to
> writel_relaxed().
>
> I did a regex search for wmb() followed by writel() in each drivers
> directory.
> I scrubbed the ones I care about in this series.
>
> I considered "ease of change", "popular usage" and "performance
> critical
> path" as the determining criteria for my filtering.
>
> We used relaxed API heavily on ARM for a long time but
> it did not exist on other architectures. For this reason, relaxed
> architectures have been paying double penalty in order to use the
> common
> drivers.
>
> Now that relaxed API is present on all architectures, we can go and
> scrub
> all drivers to see what needs to change and what can remain.
>
> We start with mostly used ones and hope to increase the coverage over
> time.
> It will take a while to cover all drivers.
>
> Feel free to apply patches individually.

I looked over the set and they seem good.

Reviewed-by: Alexander Duyck 


Grrr, patch 1 does not apply cleanly to my next-queue tree (dev-queue
branch).  I will deal with this series in a day or two, after I have 
dealt

with my driver pull requests.


Sorry, you will have to replace the ones you took from me.



>
> Changes since v6:
> clean up between 2..6 and then make your Alex's changes on 1 and 7
> The mmiowb shouldn't be needed for Rx. Only one CPU will be running
> NAPI for the queue and we will synchronize this with a full writel
> anyway when we re-enable the interrupts.
>
> Sinan Kaya (7):
>   i40e/i40evf: Eliminate duplicate barriers on weakly-ordered archs
>   ixgbe: eliminate duplicate barriers on weakly-ordered archs
>   igbvf: eliminate duplicate barriers on weakly-ordered archs
>   igb: eliminate duplicate barriers on weakly-ordered archs
>   fm10k: Eliminate duplicate barriers on weakly-ordered archs
>   ixgbevf: keep writel() closer to wmb()
>   ixgbevf: eliminate duplicate barriers on weakly-ordered archs
>
>  drivers/net/ethernet/intel/fm10k/fm10k_main.c |  4 ++--
>  drivers/net/ethernet/intel/i40e/i40e_txrx.c   | 14 ++
>  drivers/net/ethernet/intel/i40evf/i40e_txrx.c |  4 ++--
>  drivers/net/ethernet/intel/igb/igb_main.c |  4 ++--
>  drivers/net/ethernet/intel/igbvf/netdev.c |  4 ++--
>  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |  8 
>  drivers/net/ethernet/intel/ixgbevf/ixgbevf.h  |  5 -
>  drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 11 ---
>  8 files changed, 30 insertions(+), 24 deletions(-)
>
> --
> 2.7.4
>


[PATCH v5 bpf-next 09/10] samples/bpf: raw tracepoint test

2018-03-23 Thread Alexei Starovoitov
From: Alexei Starovoitov 

add empty raw_tracepoint bpf program to test overhead similar
to kprobe and traditional tracepoint tests

Signed-off-by: Alexei Starovoitov 
---
 samples/bpf/Makefile|  1 +
 samples/bpf/bpf_load.c  | 14 ++
 samples/bpf/test_overhead_raw_tp_kern.c | 17 +
 samples/bpf/test_overhead_user.c| 12 
 4 files changed, 44 insertions(+)
 create mode 100644 samples/bpf/test_overhead_raw_tp_kern.c

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 2c2a587e0942..4d6a6edd4bf6 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -119,6 +119,7 @@ always += offwaketime_kern.o
 always += spintest_kern.o
 always += map_perf_test_kern.o
 always += test_overhead_tp_kern.o
+always += test_overhead_raw_tp_kern.o
 always += test_overhead_kprobe_kern.o
 always += parse_varlen.o parse_simple.o parse_ldabs.o
 always += test_cgrp2_tc_kern.o
diff --git a/samples/bpf/bpf_load.c b/samples/bpf/bpf_load.c
index b1a310c3ae89..bebe4188b4b3 100644
--- a/samples/bpf/bpf_load.c
+++ b/samples/bpf/bpf_load.c
@@ -61,6 +61,7 @@ static int load_and_attach(const char *event, struct bpf_insn 
*prog, int size)
bool is_kprobe = strncmp(event, "kprobe/", 7) == 0;
bool is_kretprobe = strncmp(event, "kretprobe/", 10) == 0;
bool is_tracepoint = strncmp(event, "tracepoint/", 11) == 0;
+   bool is_raw_tracepoint = strncmp(event, "raw_tracepoint/", 15) == 0;
bool is_xdp = strncmp(event, "xdp", 3) == 0;
bool is_perf_event = strncmp(event, "perf_event", 10) == 0;
bool is_cgroup_skb = strncmp(event, "cgroup/skb", 10) == 0;
@@ -85,6 +86,8 @@ static int load_and_attach(const char *event, struct bpf_insn 
*prog, int size)
prog_type = BPF_PROG_TYPE_KPROBE;
} else if (is_tracepoint) {
prog_type = BPF_PROG_TYPE_TRACEPOINT;
+   } else if (is_raw_tracepoint) {
+   prog_type = BPF_PROG_TYPE_RAW_TRACEPOINT;
} else if (is_xdp) {
prog_type = BPF_PROG_TYPE_XDP;
} else if (is_perf_event) {
@@ -131,6 +134,16 @@ static int load_and_attach(const char *event, struct 
bpf_insn *prog, int size)
return populate_prog_array(event, fd);
}
 
+   if (is_raw_tracepoint) {
+   efd = bpf_raw_tracepoint_open(event + 15, fd);
+   if (efd < 0) {
+   printf("tracepoint %s %s\n", event + 15, 
strerror(errno));
+   return -1;
+   }
+   event_fd[prog_cnt - 1] = efd;
+   return 0;
+   }
+
if (is_kprobe || is_kretprobe) {
if (is_kprobe)
event += 7;
@@ -587,6 +600,7 @@ static int do_load_bpf_file(const char *path, fixup_map_cb 
fixup_map)
if (memcmp(shname, "kprobe/", 7) == 0 ||
memcmp(shname, "kretprobe/", 10) == 0 ||
memcmp(shname, "tracepoint/", 11) == 0 ||
+   memcmp(shname, "raw_tracepoint/", 15) == 0 ||
memcmp(shname, "xdp", 3) == 0 ||
memcmp(shname, "perf_event", 10) == 0 ||
memcmp(shname, "socket", 6) == 0 ||
diff --git a/samples/bpf/test_overhead_raw_tp_kern.c 
b/samples/bpf/test_overhead_raw_tp_kern.c
new file mode 100644
index ..d2af8bc1c805
--- /dev/null
+++ b/samples/bpf/test_overhead_raw_tp_kern.c
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2018 Facebook */
+#include 
+#include "bpf_helpers.h"
+
+SEC("raw_tracepoint/task_rename")
+int prog(struct bpf_raw_tracepoint_args *ctx)
+{
+   return 0;
+}
+
+SEC("raw_tracepoint/urandom_read")
+int prog2(struct bpf_raw_tracepoint_args *ctx)
+{
+   return 0;
+}
+char _license[] SEC("license") = "GPL";
diff --git a/samples/bpf/test_overhead_user.c b/samples/bpf/test_overhead_user.c
index d291167fd3c7..e1d35e07a10e 100644
--- a/samples/bpf/test_overhead_user.c
+++ b/samples/bpf/test_overhead_user.c
@@ -158,5 +158,17 @@ int main(int argc, char **argv)
unload_progs();
}
 
+   if (test_flags & 0xC0) {
+   snprintf(filename, sizeof(filename),
+"%s_raw_tp_kern.o", argv[0]);
+   if (load_bpf_file(filename)) {
+   printf("%s", bpf_log_buf);
+   return 1;
+   }
+   printf("w/RAW_TRACEPOINT\n");
+   run_perf_test(num_cpu, test_flags >> 6);
+   unload_progs();
+   }
+
return 0;
 }
-- 
2.9.5



[PATCH v5 bpf-next 07/10] bpf: introduce BPF_RAW_TRACEPOINT

2018-03-23 Thread Alexei Starovoitov
From: Alexei Starovoitov 

Introduce BPF_PROG_TYPE_RAW_TRACEPOINT bpf program type to access
kernel internal arguments of the tracepoints in their raw form.

>From bpf program point of view the access to the arguments look like:
struct bpf_raw_tracepoint_args {
   __u64 args[0];
};

int bpf_prog(struct bpf_raw_tracepoint_args *ctx)
{
  // program can read args[N] where N depends on tracepoint
  // and statically verified at program load+attach time
}

kprobe+bpf infrastructure allows programs access function arguments.
This feature allows programs access raw tracepoint arguments.

Similar to proposed 'dynamic ftrace events' there are no abi guarantees
to what the tracepoints arguments are and what their meaning is.
The program needs to type cast args properly and use bpf_probe_read()
helper to access struct fields when argument is a pointer.

For every tracepoint __bpf_trace_##call function is prepared.
In assembler it looks like:
(gdb) disassemble __bpf_trace_xdp_exception
Dump of assembler code for function __bpf_trace_xdp_exception:
   0x81132080 <+0>: mov%ecx,%ecx
   0x81132082 <+2>: jmpq   0x811231f0 

where

TRACE_EVENT(xdp_exception,
TP_PROTO(const struct net_device *dev,
 const struct bpf_prog *xdp, u32 act),

The above assembler snippet is casting 32-bit 'act' field into 'u64'
to pass into bpf_trace_run3(), while 'dev' and 'xdp' args are passed as-is.
All of ~500 of __bpf_trace_*() functions are only 5-10 byte long
and in total this approach adds 7k bytes to .text and 8k bytes
to .rodata since the probe funcs need to appear in kallsyms.
The alternative of having __bpf_trace_##call being global in kallsyms
could have been to keep them static and add another pointer to these
static functions to 'struct trace_event_class' and 'struct trace_event_call',
but keeping them global simplifies implementation and keeps it indepedent
from the tracing side.

Also such approach gives the lowest possible overhead
while calling trace_xdp_exception() from kernel C code and
transitioning into bpf land.
Since tracepoint+bpf are used at speeds of 1M+ events per second
this is very valuable optimization.

Since ftrace and perf side are not involved the new
BPF_RAW_TRACEPOINT_OPEN sys_bpf command is introduced
that returns anon_inode FD of 'bpf-raw-tracepoint' object.

The user space looks like:
// load bpf prog with BPF_PROG_TYPE_RAW_TRACEPOINT type
prog_fd = bpf_prog_load(...);
// receive anon_inode fd for given bpf_raw_tracepoint with prog attached
raw_tp_fd = bpf_raw_tracepoint_open("xdp_exception", prog_fd);

Ctrl-C of tracing daemon or cmdline tool that uses this feature
will automatically detach bpf program, unload it and
unregister tracepoint probe.

On the kernel side for_each_kernel_tracepoint() is used
to find a tracepoint with "xdp_exception" name
(that would be __tracepoint_xdp_exception record)

Then kallsyms_lookup_name() is used to find the addr
of __bpf_trace_xdp_exception() probe function.

And finally tracepoint_probe_register() is used to connect probe
with tracepoint.

Addition of bpf_raw_tracepoint doesn't interfere with ftrace and perf
tracepoint mechanisms. perf_event_open() can be used in parallel
on the same tracepoint.
Multiple bpf_raw_tracepoint_open("xdp_exception", prog_fd) are permitted.
Each with its own bpf program. The kernel will execute
all tracepoint probes and all attached bpf programs.

In the future bpf_raw_tracepoints can be extended with
query/introspection logic.

Signed-off-by: Alexei Starovoitov 
---
 include/linux/bpf_types.h|   1 +
 include/linux/trace_events.h |  37 +
 include/trace/bpf_probe.h|  87 
 include/trace/define_trace.h |   1 +
 include/uapi/linux/bpf.h |  11 +++
 kernel/bpf/syscall.c |  87 
 kernel/trace/bpf_trace.c | 188 +++
 7 files changed, 412 insertions(+)
 create mode 100644 include/trace/bpf_probe.h

diff --git a/include/linux/bpf_types.h b/include/linux/bpf_types.h
index 5e2e8a49fb21..6d7243bfb0ff 100644
--- a/include/linux/bpf_types.h
+++ b/include/linux/bpf_types.h
@@ -19,6 +19,7 @@ BPF_PROG_TYPE(BPF_PROG_TYPE_SK_MSG, sk_msg)
 BPF_PROG_TYPE(BPF_PROG_TYPE_KPROBE, kprobe)
 BPF_PROG_TYPE(BPF_PROG_TYPE_TRACEPOINT, tracepoint)
 BPF_PROG_TYPE(BPF_PROG_TYPE_PERF_EVENT, perf_event)
+BPF_PROG_TYPE(BPF_PROG_TYPE_RAW_TRACEPOINT, raw_tracepoint)
 #endif
 #ifdef CONFIG_CGROUP_BPF
 BPF_PROG_TYPE(BPF_PROG_TYPE_CGROUP_DEVICE, cg_dev)
diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
index 8a1442c4e513..e37fcd7505da 100644
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -468,6 +468,8 @@ unsigned int trace_call_bpf(struct trace_event_call *call, 
void *ctx);
 int perf_event_attach_bpf_prog(struct perf_event *event, struct bpf_prog 
*prog);
 void perf_event_detach_bpf_prog(struct perf_event *event);
 int 

[PATCH v5 bpf-next 10/10] selftests/bpf: test for bpf_get_stackid() from raw tracepoints

2018-03-23 Thread Alexei Starovoitov
From: Alexei Starovoitov 

similar to traditional traceopint test add bpf_get_stackid() test
from raw tracepoints
and reduce verbosity of existing stackmap test

Signed-off-by: Alexei Starovoitov 
---
 tools/testing/selftests/bpf/test_progs.c | 91 
 1 file changed, 70 insertions(+), 21 deletions(-)

diff --git a/tools/testing/selftests/bpf/test_progs.c 
b/tools/testing/selftests/bpf/test_progs.c
index e9df48b306df..faadbe233966 100644
--- a/tools/testing/selftests/bpf/test_progs.c
+++ b/tools/testing/selftests/bpf/test_progs.c
@@ -877,7 +877,7 @@ static void test_stacktrace_map()
 
err = bpf_prog_load(file, BPF_PROG_TYPE_TRACEPOINT, , _fd);
if (CHECK(err, "prog_load", "err %d errno %d\n", err, errno))
-   goto out;
+   return;
 
/* Get the ID for the sched/sched_switch tracepoint */
snprintf(buf, sizeof(buf),
@@ -888,8 +888,7 @@ static void test_stacktrace_map()
 
bytes = read(efd, buf, sizeof(buf));
close(efd);
-   if (CHECK(bytes <= 0 || bytes >= sizeof(buf),
- "read", "bytes %d errno %d\n", bytes, errno))
+   if (bytes <= 0 || bytes >= sizeof(buf))
goto close_prog;
 
/* Open the perf event and attach bpf progrram */
@@ -906,29 +905,24 @@ static void test_stacktrace_map()
goto close_prog;
 
err = ioctl(pmu_fd, PERF_EVENT_IOC_ENABLE, 0);
-   if (CHECK(err, "perf_event_ioc_enable", "err %d errno %d\n",
- err, errno))
-   goto close_pmu;
+   if (err)
+   goto disable_pmu;
 
err = ioctl(pmu_fd, PERF_EVENT_IOC_SET_BPF, prog_fd);
-   if (CHECK(err, "perf_event_ioc_set_bpf", "err %d errno %d\n",
- err, errno))
+   if (err)
goto disable_pmu;
 
/* find map fds */
control_map_fd = bpf_find_map(__func__, obj, "control_map");
-   if (CHECK(control_map_fd < 0, "bpf_find_map control_map",
- "err %d errno %d\n", err, errno))
+   if (control_map_fd < 0)
goto disable_pmu;
 
stackid_hmap_fd = bpf_find_map(__func__, obj, "stackid_hmap");
-   if (CHECK(stackid_hmap_fd < 0, "bpf_find_map stackid_hmap",
- "err %d errno %d\n", err, errno))
+   if (stackid_hmap_fd < 0)
goto disable_pmu;
 
stackmap_fd = bpf_find_map(__func__, obj, "stackmap");
-   if (CHECK(stackmap_fd < 0, "bpf_find_map stackmap", "err %d errno %d\n",
- err, errno))
+   if (stackmap_fd < 0)
goto disable_pmu;
 
/* give some time for bpf program run */
@@ -945,24 +939,78 @@ static void test_stacktrace_map()
err = compare_map_keys(stackid_hmap_fd, stackmap_fd);
if (CHECK(err, "compare_map_keys stackid_hmap vs. stackmap",
  "err %d errno %d\n", err, errno))
-   goto disable_pmu;
+   goto disable_pmu_noerr;
 
err = compare_map_keys(stackmap_fd, stackid_hmap_fd);
if (CHECK(err, "compare_map_keys stackmap vs. stackid_hmap",
  "err %d errno %d\n", err, errno))
-   ; /* fall through */
+   goto disable_pmu_noerr;
 
+   goto disable_pmu_noerr;
 disable_pmu:
+   error_cnt++;
+disable_pmu_noerr:
ioctl(pmu_fd, PERF_EVENT_IOC_DISABLE);
-
-close_pmu:
close(pmu_fd);
-
 close_prog:
bpf_object__close(obj);
+}
 
-out:
-   return;
+static void test_stacktrace_map_raw_tp()
+{
+   int control_map_fd, stackid_hmap_fd, stackmap_fd;
+   const char *file = "./test_stacktrace_map.o";
+   int efd, err, prog_fd;
+   __u32 key, val, duration = 0;
+   struct bpf_object *obj;
+
+   err = bpf_prog_load(file, BPF_PROG_TYPE_RAW_TRACEPOINT, , _fd);
+   if (CHECK(err, "prog_load raw tp", "err %d errno %d\n", err, errno))
+   return;
+
+   efd = bpf_raw_tracepoint_open("sched_switch", prog_fd);
+   if (CHECK(efd < 0, "raw_tp_open", "err %d errno %d\n", efd, errno))
+   goto close_prog;
+
+   /* find map fds */
+   control_map_fd = bpf_find_map(__func__, obj, "control_map");
+   if (control_map_fd < 0)
+   goto close_prog;
+
+   stackid_hmap_fd = bpf_find_map(__func__, obj, "stackid_hmap");
+   if (stackid_hmap_fd < 0)
+   goto close_prog;
+
+   stackmap_fd = bpf_find_map(__func__, obj, "stackmap");
+   if (stackmap_fd < 0)
+   goto close_prog;
+
+   /* give some time for bpf program run */
+   sleep(1);
+
+   /* disable stack trace collection */
+   key = 0;
+   val = 1;
+   bpf_map_update_elem(control_map_fd, , , 0);
+
+   /* for every element in stackid_hmap, we can find a corresponding one
+* in stackmap, and vise versa.
+*/
+   err = compare_map_keys(stackid_hmap_fd, stackmap_fd);
+   if (CHECK(err, "compare_map_keys 

[PATCH v5 bpf-next 05/10] macro: introduce COUNT_ARGS() macro

2018-03-23 Thread Alexei Starovoitov
From: Alexei Starovoitov 

move COUNT_ARGS() macro from apparmor to generic header and extend it
to count till twelve.

COUNT() was an alternative name for this logic, but it's used for
different purpose in many other places.

Similarly for CONCATENATE() macro.

Suggested-by: Linus Torvalds 
Signed-off-by: Alexei Starovoitov 
---
 include/linux/kernel.h   | 7 +++
 security/apparmor/include/path.h | 7 +--
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 3fd291503576..293fa0677fba 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -919,6 +919,13 @@ static inline void ftrace_dump(enum ftrace_dump_mode 
oops_dump_mode) { }
 #define swap(a, b) \
do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
 
+/* This counts to 12. Any more, it will return 13th argument. */
+#define __COUNT_ARGS(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, 
_n, X...) _n
+#define COUNT_ARGS(X...) __COUNT_ARGS(, ##X, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 
2, 1, 0)
+
+#define __CONCAT(a, b) a ## b
+#define CONCATENATE(a, b) __CONCAT(a, b)
+
 /**
  * container_of - cast a member of a structure out to the containing structure
  * @ptr:   the pointer to the member.
diff --git a/security/apparmor/include/path.h b/security/apparmor/include/path.h
index 05fb3305671e..e042b994f2b8 100644
--- a/security/apparmor/include/path.h
+++ b/security/apparmor/include/path.h
@@ -43,15 +43,10 @@ struct aa_buffers {
 
 DECLARE_PER_CPU(struct aa_buffers, aa_buffers);
 
-#define COUNT_ARGS(X...) COUNT_ARGS_HELPER(, ##X, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
-#define COUNT_ARGS_HELPER(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, n, X...) n
-#define CONCAT(X, Y) X ## Y
-#define CONCAT_AFTER(X, Y) CONCAT(X, Y)
-
 #define ASSIGN(FN, X, N) ((X) = FN(N))
 #define EVAL1(FN, X) ASSIGN(FN, X, 0) /*X = FN(0)*/
 #define EVAL2(FN, X, Y...) do { ASSIGN(FN, X, 1);  EVAL1(FN, Y); } while (0)
-#define EVAL(FN, X...) CONCAT_AFTER(EVAL, COUNT_ARGS(X))(FN, X)
+#define EVAL(FN, X...) CONCATENATE(EVAL, COUNT_ARGS(X))(FN, X)
 
 #define for_each_cpu_buffer(I) for ((I) = 0; (I) < MAX_PATH_BUFFERS; (I)++)
 
-- 
2.9.5



[PATCH v5 bpf-next 01/10] treewide: remove large struct-pass-by-value from tracepoint arguments

2018-03-23 Thread Alexei Starovoitov
From: Alexei Starovoitov 

- fix trace_hfi1_ctxt_info() to pass large struct by reference instead of by 
value
- convert 'type array[]' tracepoint arguments into 'type *array',
  since compiler will warn that sizeof('type array[]') == sizeof('type *array')
  and later should be used instead

The CAST_TO_U64 macro in the later patch will enforce that tracepoint
arguments can only be integers, pointers, or less than 8 byte structures.
Larger structures should be passed by reference.

Signed-off-by: Alexei Starovoitov 
---
 drivers/infiniband/hw/hfi1/file_ops.c|  2 +-
 drivers/infiniband/hw/hfi1/trace_ctxts.h | 12 ++--
 include/trace/events/f2fs.h  |  2 +-
 net/wireless/trace.h |  2 +-
 sound/firewire/amdtp-stream-trace.h  |  2 +-
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/file_ops.c 
b/drivers/infiniband/hw/hfi1/file_ops.c
index 41fafebe3b0d..da4aa1a95b11 100644
--- a/drivers/infiniband/hw/hfi1/file_ops.c
+++ b/drivers/infiniband/hw/hfi1/file_ops.c
@@ -1153,7 +1153,7 @@ static int get_ctxt_info(struct hfi1_filedata *fd, 
unsigned long arg, u32 len)
cinfo.sdma_ring_size = fd->cq->nentries;
cinfo.rcvegr_size = uctxt->egrbufs.rcvtid_size;
 
-   trace_hfi1_ctxt_info(uctxt->dd, uctxt->ctxt, fd->subctxt, cinfo);
+   trace_hfi1_ctxt_info(uctxt->dd, uctxt->ctxt, fd->subctxt, );
if (copy_to_user((void __user *)arg, , len))
return -EFAULT;
 
diff --git a/drivers/infiniband/hw/hfi1/trace_ctxts.h 
b/drivers/infiniband/hw/hfi1/trace_ctxts.h
index 4eb4cc798035..e00c8a7d559c 100644
--- a/drivers/infiniband/hw/hfi1/trace_ctxts.h
+++ b/drivers/infiniband/hw/hfi1/trace_ctxts.h
@@ -106,7 +106,7 @@ TRACE_EVENT(hfi1_uctxtdata,
 TRACE_EVENT(hfi1_ctxt_info,
TP_PROTO(struct hfi1_devdata *dd, unsigned int ctxt,
 unsigned int subctxt,
-struct hfi1_ctxt_info cinfo),
+struct hfi1_ctxt_info *cinfo),
TP_ARGS(dd, ctxt, subctxt, cinfo),
TP_STRUCT__entry(DD_DEV_ENTRY(dd)
 __field(unsigned int, ctxt)
@@ -120,11 +120,11 @@ TRACE_EVENT(hfi1_ctxt_info,
TP_fast_assign(DD_DEV_ASSIGN(dd);
__entry->ctxt = ctxt;
__entry->subctxt = subctxt;
-   __entry->egrtids = cinfo.egrtids;
-   __entry->rcvhdrq_cnt = cinfo.rcvhdrq_cnt;
-   __entry->rcvhdrq_size = cinfo.rcvhdrq_entsize;
-   __entry->sdma_ring_size = cinfo.sdma_ring_size;
-   __entry->rcvegr_size = cinfo.rcvegr_size;
+   __entry->egrtids = cinfo->egrtids;
+   __entry->rcvhdrq_cnt = cinfo->rcvhdrq_cnt;
+   __entry->rcvhdrq_size = cinfo->rcvhdrq_entsize;
+   __entry->sdma_ring_size = cinfo->sdma_ring_size;
+   __entry->rcvegr_size = cinfo->rcvegr_size;
),
TP_printk("[%s] ctxt %u:%u " CINFO_FMT,
  __get_str(dev),
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index 06c87f9f720c..795698925d20 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -491,7 +491,7 @@ DEFINE_EVENT(f2fs__truncate_node, f2fs_truncate_node,
 
 TRACE_EVENT(f2fs_truncate_partial_nodes,
 
-   TP_PROTO(struct inode *inode, nid_t nid[], int depth, int err),
+   TP_PROTO(struct inode *inode, nid_t *nid, int depth, int err),
 
TP_ARGS(inode, nid, depth, err),
 
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index 5152938b358d..018c81fa72fb 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -3137,7 +3137,7 @@ TRACE_EVENT(rdev_start_radar_detection,
 
 TRACE_EVENT(rdev_set_mcast_rate,
TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
-int mcast_rate[NUM_NL80211_BANDS]),
+int *mcast_rate),
TP_ARGS(wiphy, netdev, mcast_rate),
TP_STRUCT__entry(
WIPHY_ENTRY
diff --git a/sound/firewire/amdtp-stream-trace.h 
b/sound/firewire/amdtp-stream-trace.h
index ea0d486652c8..54cdd4ffa9ce 100644
--- a/sound/firewire/amdtp-stream-trace.h
+++ b/sound/firewire/amdtp-stream-trace.h
@@ -14,7 +14,7 @@
 #include 
 
 TRACE_EVENT(in_packet,
-   TP_PROTO(const struct amdtp_stream *s, u32 cycles, u32 cip_header[2], 
unsigned int payload_length, unsigned int index),
+   TP_PROTO(const struct amdtp_stream *s, u32 cycles, u32 *cip_header, 
unsigned int payload_length, unsigned int index),
TP_ARGS(s, cycles, cip_header, payload_length, index),
TP_STRUCT__entry(
__field(unsigned int, second)
-- 
2.9.5



[PATCH v5 bpf-next 00/10] bpf, tracing: introduce bpf raw tracepoints

2018-03-23 Thread Alexei Starovoitov
From: Alexei Starovoitov 

v4->v5:
- adopted Daniel's fancy REPEAT macro in bpf_trace.c in patch 7
  
v3->v4:
- adopted Linus's CAST_TO_U64 macro to cast any integer, pointer, or small
  struct to u64. That nicely reduced the size of patch 1

v2->v3:
- with Linus's suggestion introduced generic COUNT_ARGS and CONCATENATE macros
  (or rather moved them from apparmor)
  that cleaned up patches 6 and 7
- added patch 4 to refactor trace_iwlwifi_dev_ucode_error() from 17 args to 4
  Now any tracepoint with >12 args will have build error

v1->v2:
- simplified api by combing bpf_raw_tp_open(name) + bpf_attach(prog_fd) into
  bpf_raw_tp_open(name, prog_fd) as suggested by Daniel.
  That simplifies bpf_detach as well which is now simple close() of fd.
- fixed memory leak in error path which was spotted by Daniel.
- fixed bpf_get_stackid(), bpf_perf_event_output() called from raw tracepoints
- added more tests
- fixed allyesconfig build caught by buildbot

v1:
This patch set is a different way to address the pressing need to access
task_struct pointers in sched tracepoints from bpf programs.

The first approach simply added these pointers to sched tracepoints:
https://lkml.org/lkml/2017/12/14/753
which Peter nacked.
Few options were discussed and eventually the discussion converged on
doing bpf specific tracepoint_probe_register() probe functions.
Details here:
https://lkml.org/lkml/2017/12/20/929

Patch 1 is kernel wide cleanup of pass-struct-by-value into
pass-struct-by-reference into tracepoints.

Patches 2 and 3 are minor cleanups to address allyesconfig build

Patch 4 refactor trace_iwlwifi_dev_ucode_error from 17 to 4 args

Patch 5 introduces COUNT_ARGS macro

Patch 6 minor prep work to expose number of arguments passed
into tracepoints.

Patch 7 introduces BPF_RAW_TRACEPOINT api.
the auto-cleanup and multiple concurrent users are must have
features of tracing api. For bpf raw tracepoints it looks like:
  // load bpf prog with BPF_PROG_TYPE_RAW_TRACEPOINT type
  prog_fd = bpf_prog_load(...);

  // receive anon_inode fd for given bpf_raw_tracepoint
  // and attach bpf program to it
  raw_tp_fd = bpf_raw_tracepoint_open("xdp_exception", prog_fd);

Ctrl-C of tracing daemon or cmdline tool will automatically
detach bpf program, unload it and unregister tracepoint probe.
More details in patch 7.

Patch 8 - trivial support in libbpf
Patches 9, 10 - user space tests

samples/bpf/test_overhead performance on 1 cpu:

tracepointbase  kprobe+bpf tracepoint+bpf raw_tracepoint+bpf
task_rename   1.1M   769K947K1.0M
urandom_read  789K   697K750K755K

Alexei Starovoitov (10):
  treewide: remove large struct-pass-by-value from tracepoint arguments
  net/mediatek: disambiguate mt76 vs mt7601u trace events
  net/mac802154: disambiguate mac80215 vs mac802154 trace events
  net/wireless/iwlwifi: fix iwlwifi_dev_ucode_error tracepoint
  macro: introduce COUNT_ARGS() macro
  tracepoint: compute num_args at build time
  bpf: introduce BPF_RAW_TRACEPOINT
  libbpf: add bpf_raw_tracepoint_open helper
  samples/bpf: raw tracepoint test
  selftests/bpf: test for bpf_get_stackid() from raw tracepoints

 drivers/infiniband/hw/hfi1/file_ops.c  |   2 +-
 drivers/infiniband/hw/hfi1/trace_ctxts.h   |  12 +-
 drivers/net/wireless/intel/iwlwifi/dvm/main.c  |   7 +-
 .../wireless/intel/iwlwifi/iwl-devtrace-iwlwifi.h  |  39 ++---
 drivers/net/wireless/intel/iwlwifi/iwl-devtrace.c  |   1 +
 drivers/net/wireless/intel/iwlwifi/mvm/utils.c |   7 +-
 drivers/net/wireless/mediatek/mt7601u/trace.h  |   6 +-
 include/linux/bpf_types.h  |   1 +
 include/linux/kernel.h |   7 +
 include/linux/trace_events.h   |  37 
 include/linux/tracepoint-defs.h|   1 +
 include/linux/tracepoint.h |  28 ++-
 include/trace/bpf_probe.h  |  87 ++
 include/trace/define_trace.h   |  15 +-
 include/trace/events/f2fs.h|   2 +-
 include/uapi/linux/bpf.h   |  11 ++
 kernel/bpf/syscall.c   |  87 ++
 kernel/trace/bpf_trace.c   | 188 +
 kernel/tracepoint.c|  27 +--
 net/mac802154/trace.h  |   8 +-
 net/wireless/trace.h   |   2 +-
 samples/bpf/Makefile   |   1 +
 samples/bpf/bpf_load.c |  14 ++
 samples/bpf/test_overhead_raw_tp_kern.c|  17 ++
 samples/bpf/test_overhead_user.c   |  12 ++
 security/apparmor/include/path.h   |   7 +-
 sound/firewire/amdtp-stream-trace.h|   2 +-
 tools/include/uapi/linux/bpf.h |  11 ++
 tools/lib/bpf/bpf.c|  11 ++
 

[PATCH v5 bpf-next 03/10] net/mac802154: disambiguate mac80215 vs mac802154 trace events

2018-03-23 Thread Alexei Starovoitov
From: Alexei Starovoitov 

two trace events defined with the same name and both unused.
They conflict in allyesconfig build. Rename one of them.

Signed-off-by: Alexei Starovoitov 
---
 net/mac802154/trace.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/mac802154/trace.h b/net/mac802154/trace.h
index 2c8a43d3607f..df855c33daf2 100644
--- a/net/mac802154/trace.h
+++ b/net/mac802154/trace.h
@@ -33,7 +33,7 @@
 
 /* Tracing for driver callbacks */
 
-DECLARE_EVENT_CLASS(local_only_evt,
+DECLARE_EVENT_CLASS(local_only_evt4,
TP_PROTO(struct ieee802154_local *local),
TP_ARGS(local),
TP_STRUCT__entry(
@@ -45,7 +45,7 @@ DECLARE_EVENT_CLASS(local_only_evt,
TP_printk(LOCAL_PR_FMT, LOCAL_PR_ARG)
 );
 
-DEFINE_EVENT(local_only_evt, 802154_drv_return_void,
+DEFINE_EVENT(local_only_evt4, 802154_drv_return_void,
TP_PROTO(struct ieee802154_local *local),
TP_ARGS(local)
 );
@@ -65,12 +65,12 @@ TRACE_EVENT(802154_drv_return_int,
  __entry->ret)
 );
 
-DEFINE_EVENT(local_only_evt, 802154_drv_start,
+DEFINE_EVENT(local_only_evt4, 802154_drv_start,
TP_PROTO(struct ieee802154_local *local),
TP_ARGS(local)
 );
 
-DEFINE_EVENT(local_only_evt, 802154_drv_stop,
+DEFINE_EVENT(local_only_evt4, 802154_drv_stop,
TP_PROTO(struct ieee802154_local *local),
TP_ARGS(local)
 );
-- 
2.9.5



[PATCH v5 bpf-next 08/10] libbpf: add bpf_raw_tracepoint_open helper

2018-03-23 Thread Alexei Starovoitov
From: Alexei Starovoitov 

add bpf_raw_tracepoint_open(const char *name, int prog_fd) api to libbpf

Signed-off-by: Alexei Starovoitov 
---
 tools/include/uapi/linux/bpf.h | 11 +++
 tools/lib/bpf/bpf.c| 11 +++
 tools/lib/bpf/bpf.h|  1 +
 3 files changed, 23 insertions(+)

diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index d245c41213ac..58060bec999d 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -94,6 +94,7 @@ enum bpf_cmd {
BPF_MAP_GET_FD_BY_ID,
BPF_OBJ_GET_INFO_BY_FD,
BPF_PROG_QUERY,
+   BPF_RAW_TRACEPOINT_OPEN,
 };
 
 enum bpf_map_type {
@@ -134,6 +135,7 @@ enum bpf_prog_type {
BPF_PROG_TYPE_SK_SKB,
BPF_PROG_TYPE_CGROUP_DEVICE,
BPF_PROG_TYPE_SK_MSG,
+   BPF_PROG_TYPE_RAW_TRACEPOINT,
 };
 
 enum bpf_attach_type {
@@ -344,6 +346,11 @@ union bpf_attr {
__aligned_u64   prog_ids;
__u32   prog_cnt;
} query;
+
+   struct {
+   __u64 name;
+   __u32 prog_fd;
+   } raw_tracepoint;
 } __attribute__((aligned(8)));
 
 /* BPF helper function descriptions:
@@ -1151,4 +1158,8 @@ struct bpf_cgroup_dev_ctx {
__u32 minor;
 };
 
+struct bpf_raw_tracepoint_args {
+   __u64 args[0];
+};
+
 #endif /* _UAPI__LINUX_BPF_H__ */
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index 592a58a2b681..e0500055f1a6 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -428,6 +428,17 @@ int bpf_obj_get_info_by_fd(int prog_fd, void *info, __u32 
*info_len)
return err;
 }
 
+int bpf_raw_tracepoint_open(const char *name, int prog_fd)
+{
+   union bpf_attr attr;
+
+   bzero(, sizeof(attr));
+   attr.raw_tracepoint.name = ptr_to_u64(name);
+   attr.raw_tracepoint.prog_fd = prog_fd;
+
+   return sys_bpf(BPF_RAW_TRACEPOINT_OPEN, , sizeof(attr));
+}
+
 int bpf_set_link_xdp_fd(int ifindex, int fd, __u32 flags)
 {
struct sockaddr_nl sa;
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h
index 8d18fb73d7fb..ee59342c6f42 100644
--- a/tools/lib/bpf/bpf.h
+++ b/tools/lib/bpf/bpf.h
@@ -79,4 +79,5 @@ int bpf_map_get_fd_by_id(__u32 id);
 int bpf_obj_get_info_by_fd(int prog_fd, void *info, __u32 *info_len);
 int bpf_prog_query(int target_fd, enum bpf_attach_type type, __u32 query_flags,
   __u32 *attach_flags, __u32 *prog_ids, __u32 *prog_cnt);
+int bpf_raw_tracepoint_open(const char *name, int prog_fd);
 #endif
-- 
2.9.5



[PATCH v5 bpf-next 06/10] tracepoint: compute num_args at build time

2018-03-23 Thread Alexei Starovoitov
From: Alexei Starovoitov 

add fancy macro to compute number of arguments passed into tracepoint
at compile time and store it as part of 'struct tracepoint'.
The number is necessary to check safety of bpf program access that
is coming in subsequent patch.

for_each_tracepoint_range() api has no users inside the kernel.
Make it more useful with ability to stop for_each() loop depending
via callback return value.
In such form it's used in subsequent patch.

Signed-off-by: Alexei Starovoitov 
---
 include/linux/tracepoint-defs.h |  1 +
 include/linux/tracepoint.h  | 28 +++-
 include/trace/define_trace.h| 14 +++---
 kernel/tracepoint.c | 27 ---
 4 files changed, 43 insertions(+), 27 deletions(-)

diff --git a/include/linux/tracepoint-defs.h b/include/linux/tracepoint-defs.h
index 64ed7064f1fa..39a283c61c51 100644
--- a/include/linux/tracepoint-defs.h
+++ b/include/linux/tracepoint-defs.h
@@ -33,6 +33,7 @@ struct tracepoint {
int (*regfunc)(void);
void (*unregfunc)(void);
struct tracepoint_func __rcu *funcs;
+   u32 num_args;
 };
 
 #endif
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index c94f466d57ef..2194e7c31484 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -40,9 +40,19 @@ tracepoint_probe_register_prio(struct tracepoint *tp, void 
*probe, void *data,
   int prio);
 extern int
 tracepoint_probe_unregister(struct tracepoint *tp, void *probe, void *data);
-extern void
-for_each_kernel_tracepoint(void (*fct)(struct tracepoint *tp, void *priv),
-   void *priv);
+
+#ifdef CONFIG_TRACEPOINTS
+void *
+for_each_kernel_tracepoint(void *(*fct)(struct tracepoint *tp, void *priv),
+  void *priv);
+#else
+static inline void *
+for_each_kernel_tracepoint(void *(*fct)(struct tracepoint *tp, void *priv),
+  void *priv)
+{
+   return NULL;
+}
+#endif
 
 #ifdef CONFIG_MODULES
 struct tp_module {
@@ -230,18 +240,18 @@ extern void syscall_unregfunc(void);
  * structures, so we create an array of pointers that will be used for 
iteration
  * on the tracepoints.
  */
-#define DEFINE_TRACE_FN(name, reg, unreg)   \
+#define DEFINE_TRACE_FN(name, reg, unreg, num_args) \
static const char __tpstrtab_##name[]\
__attribute__((section("__tracepoints_strings"))) = #name;   \
struct tracepoint __tracepoint_##name\
__attribute__((section("__tracepoints"))) =  \
-   { __tpstrtab_##name, STATIC_KEY_INIT_FALSE, reg, unreg, NULL };\
+   { __tpstrtab_##name, STATIC_KEY_INIT_FALSE, reg, unreg, NULL, 
num_args };\
static struct tracepoint * const __tracepoint_ptr_##name __used  \
__attribute__((section("__tracepoints_ptrs"))) = \
&__tracepoint_##name;
 
-#define DEFINE_TRACE(name) \
-   DEFINE_TRACE_FN(name, NULL, NULL);
+#define DEFINE_TRACE(name, num_args)   \
+   DEFINE_TRACE_FN(name, NULL, NULL, num_args);
 
 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name) \
EXPORT_SYMBOL_GPL(__tracepoint_##name)
@@ -275,8 +285,8 @@ extern void syscall_unregfunc(void);
return false;   \
}
 
-#define DEFINE_TRACE_FN(name, reg, unreg)
-#define DEFINE_TRACE(name)
+#define DEFINE_TRACE_FN(name, reg, unreg, num_args)
+#define DEFINE_TRACE(name, num_args)
 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
 #define EXPORT_TRACEPOINT_SYMBOL(name)
 
diff --git a/include/trace/define_trace.h b/include/trace/define_trace.h
index d9e3d4aa3f6e..96b22ace9ae7 100644
--- a/include/trace/define_trace.h
+++ b/include/trace/define_trace.h
@@ -25,7 +25,7 @@
 
 #undef TRACE_EVENT
 #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
-   DEFINE_TRACE(name)
+   DEFINE_TRACE(name, COUNT_ARGS(args))
 
 #undef TRACE_EVENT_CONDITION
 #define TRACE_EVENT_CONDITION(name, proto, args, cond, tstruct, assign, print) 
\
@@ -39,24 +39,24 @@
 #undef TRACE_EVENT_FN
 #define TRACE_EVENT_FN(name, proto, args, tstruct, \
assign, print, reg, unreg)  \
-   DEFINE_TRACE_FN(name, reg, unreg)
+   DEFINE_TRACE_FN(name, reg, unreg, COUNT_ARGS(args))
 
 #undef TRACE_EVENT_FN_COND
 #define TRACE_EVENT_FN_COND(name, proto, args, cond, tstruct,  \
assign, print, reg, unreg)  \
-   DEFINE_TRACE_FN(name, reg, unreg)
+   DEFINE_TRACE_FN(name, reg, unreg, COUNT_ARGS(args))
 
 #undef DEFINE_EVENT
 #define DEFINE_EVENT(template, name, proto, args) \
-   DEFINE_TRACE(name)
+   DEFINE_TRACE(name, 

[PATCH v5 bpf-next 04/10] net/wireless/iwlwifi: fix iwlwifi_dev_ucode_error tracepoint

2018-03-23 Thread Alexei Starovoitov
From: Alexei Starovoitov 

fix iwlwifi_dev_ucode_error tracepoint to pass pointer to a table
instead of all 17 arguments by value.
dvm/main.c and mvm/utils.c have 'struct iwl_error_event_table'
defined with very similar yet subtly different fields and offsets.
tracepoint is still common and using definition of 'struct 
iwl_error_event_table'
from dvm/commands.h while copying fields.
Long term this tracepoint probably should be split into two.

Signed-off-by: Alexei Starovoitov 
---
 drivers/net/wireless/intel/iwlwifi/dvm/main.c  |  7 +---
 .../wireless/intel/iwlwifi/iwl-devtrace-iwlwifi.h  | 39 ++
 drivers/net/wireless/intel/iwlwifi/iwl-devtrace.c  |  1 +
 drivers/net/wireless/intel/iwlwifi/mvm/utils.c |  7 +---
 4 files changed, 21 insertions(+), 33 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/main.c 
b/drivers/net/wireless/intel/iwlwifi/dvm/main.c
index d11d72615de2..e68254e12764 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/main.c
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/main.c
@@ -1651,12 +1651,7 @@ static void iwl_dump_nic_error_log(struct iwl_priv *priv)
priv->status, table.valid);
}
 
-   trace_iwlwifi_dev_ucode_error(trans->dev, table.error_id, table.tsf_low,
- table.data1, table.data2, table.line,
- table.blink2, table.ilink1, table.ilink2,
- table.bcon_time, table.gp1, table.gp2,
- table.gp3, table.ucode_ver, table.hw_ver,
- 0, table.brd_ver);
+   trace_iwlwifi_dev_ucode_error(trans->dev, , 0, table.brd_ver);
IWL_ERR(priv, "0x%08X | %-28s\n", table.error_id,
desc_lookup(table.error_id));
IWL_ERR(priv, "0x%08X | uPc\n", table.pc);
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-devtrace-iwlwifi.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-devtrace-iwlwifi.h
index 9518a82f44c2..27e3e4e96aa2 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-devtrace-iwlwifi.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-devtrace-iwlwifi.h
@@ -126,14 +126,11 @@ TRACE_EVENT(iwlwifi_dev_tx,
  __entry->framelen, __entry->skbaddr)
 );
 
+struct iwl_error_event_table;
 TRACE_EVENT(iwlwifi_dev_ucode_error,
-   TP_PROTO(const struct device *dev, u32 desc, u32 tsf_low,
-u32 data1, u32 data2, u32 line, u32 blink2, u32 ilink1,
-u32 ilink2, u32 bcon_time, u32 gp1, u32 gp2, u32 rev_type,
-u32 major, u32 minor, u32 hw_ver, u32 brd_ver),
-   TP_ARGS(dev, desc, tsf_low, data1, data2, line,
-blink2, ilink1, ilink2, bcon_time, gp1, gp2,
-rev_type, major, minor, hw_ver, brd_ver),
+   TP_PROTO(const struct device *dev, const struct iwl_error_event_table 
*table,
+u32 hw_ver, u32 brd_ver),
+   TP_ARGS(dev, table, hw_ver, brd_ver),
TP_STRUCT__entry(
DEV_ENTRY
__field(u32, desc)
@@ -155,20 +152,20 @@ TRACE_EVENT(iwlwifi_dev_ucode_error,
),
TP_fast_assign(
DEV_ASSIGN;
-   __entry->desc = desc;
-   __entry->tsf_low = tsf_low;
-   __entry->data1 = data1;
-   __entry->data2 = data2;
-   __entry->line = line;
-   __entry->blink2 = blink2;
-   __entry->ilink1 = ilink1;
-   __entry->ilink2 = ilink2;
-   __entry->bcon_time = bcon_time;
-   __entry->gp1 = gp1;
-   __entry->gp2 = gp2;
-   __entry->rev_type = rev_type;
-   __entry->major = major;
-   __entry->minor = minor;
+   __entry->desc = table->error_id;
+   __entry->tsf_low = table->tsf_low;
+   __entry->data1 = table->data1;
+   __entry->data2 = table->data2;
+   __entry->line = table->line;
+   __entry->blink2 = table->blink2;
+   __entry->ilink1 = table->ilink1;
+   __entry->ilink2 = table->ilink2;
+   __entry->bcon_time = table->bcon_time;
+   __entry->gp1 = table->gp1;
+   __entry->gp2 = table->gp2;
+   __entry->rev_type = table->gp3;
+   __entry->major = table->ucode_ver;
+   __entry->minor = table->hw_ver;
__entry->hw_ver = hw_ver;
__entry->brd_ver = brd_ver;
),
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.c
index 50510fb6ab8c..6aa719865a58 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.c
@@ -30,6 +30,7 @@
 #ifndef __CHECKER__
 #include "iwl-trans.h"
 
+#include "dvm/commands.h"
 #define CREATE_TRACE_POINTS
 #include "iwl-devtrace.h"
 
diff 

[PATCH v5 bpf-next 02/10] net/mediatek: disambiguate mt76 vs mt7601u trace events

2018-03-23 Thread Alexei Starovoitov
From: Alexei Starovoitov 

two trace events defined with the same name and both unused.
They conflict in allyesconfig build. Rename one of them.

Signed-off-by: Alexei Starovoitov 
---
 drivers/net/wireless/mediatek/mt7601u/trace.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt7601u/trace.h 
b/drivers/net/wireless/mediatek/mt7601u/trace.h
index 289897300ef0..82c8898b9076 100644
--- a/drivers/net/wireless/mediatek/mt7601u/trace.h
+++ b/drivers/net/wireless/mediatek/mt7601u/trace.h
@@ -34,7 +34,7 @@
 #define REG_PR_FMT "%04x=%08x"
 #define REG_PR_ARG __entry->reg, __entry->val
 
-DECLARE_EVENT_CLASS(dev_reg_evt,
+DECLARE_EVENT_CLASS(dev_reg_evtu,
TP_PROTO(struct mt7601u_dev *dev, u32 reg, u32 val),
TP_ARGS(dev, reg, val),
TP_STRUCT__entry(
@@ -51,12 +51,12 @@ DECLARE_EVENT_CLASS(dev_reg_evt,
)
 );
 
-DEFINE_EVENT(dev_reg_evt, reg_read,
+DEFINE_EVENT(dev_reg_evtu, reg_read,
TP_PROTO(struct mt7601u_dev *dev, u32 reg, u32 val),
TP_ARGS(dev, reg, val)
 );
 
-DEFINE_EVENT(dev_reg_evt, reg_write,
+DEFINE_EVENT(dev_reg_evtu, reg_write,
TP_PROTO(struct mt7601u_dev *dev, u32 reg, u32 val),
TP_ARGS(dev, reg, val)
 );
-- 
2.9.5



Re: [PATCH v2 bpf-next 5/8] bpf: introduce BPF_RAW_TRACEPOINT

2018-03-23 Thread Linus Torvalds
On Fri, Mar 23, 2018 at 6:43 PM, Alexei Starovoitov  wrote:
>
> it's not the limit I'm hitting, but self referential issue.
> Exactly half gets expanded.
> I don't think there is an easy workaround other
> than duplicating the whole chain of REPEAT macro twice
> with slightly different name.

Take a look at the __MAP() macro in include/linux/syscalls.h.

It basically takes a "transformation" as its argument, and does it 
times, where 'n' is the first argument (but could be self-counting).

Maybe it will give you some ideas.

... and maybe it will just drive you mad and make you gouge out your
eyes with a spoon. Don't blame the messenger.

 Linus


Re: [PATCH net-next] net/sched: act_vlan: declare push_vid with host byte order

2018-03-23 Thread David Miller
From: Davide Caratti 
Date: Fri, 23 Mar 2018 19:31:30 +0100

> use u16 in place of __be16 to suppress the following sparse warnings:
> 
>  net/sched/act_vlan.c:150:26: warning: incorrect type in assignment 
> (different base types)
>  net/sched/act_vlan.c:150:26: expected restricted __be16 [usertype] push_vid
>  net/sched/act_vlan.c:150:26: got unsigned short
>  net/sched/act_vlan.c:151:21: warning: restricted __be16 degrades to integer
>  net/sched/act_vlan.c:208:26: warning: incorrect type in assignment 
> (different base types)
>  net/sched/act_vlan.c:208:26: expected unsigned short [unsigned] [usertype] 
> tcfv_push_vid
>  net/sched/act_vlan.c:208:26: got restricted __be16 [usertype] push_vid
> 
> Signed-off-by: Davide Caratti 

Also applied, thanks Davide.


Re: [PATCH net-next] net/sched: remove tcf_idr_cleanup()

2018-03-23 Thread David Miller
From: Davide Caratti 
Date: Fri, 23 Mar 2018 19:09:39 +0100

> tcf_idr_cleanup() is no more used, so remove it.
> 
> Suggested-by: Cong Wang 
> Signed-off-by: Davide Caratti 

Applied, thank you.


Re: [PATCH net-next] mlxsw: spectrum_span: Prevent duplicate mirrors

2018-03-23 Thread David Miller
From: Ido Schimmel 
Date: Fri, 23 Mar 2018 21:03:58 +0300

> In net commit 8175f7c4736f ("mlxsw: spectrum: Prevent duplicate
> mirrors") we prevented the user from mirroring more than once from a
> single binding point (port-direction pair).
> 
> The fix was essentially reverted in a merge conflict resolution when net
> was merged into net-next. Restore it.
> 
> Fixes: 03fe2debbb27 ("Merge 
> git://git.kernel.org/pub/scm/linux/kernel/git/davem/net")
> Signed-off-by: Petr Machata 
> Signed-off-by: Ido Schimmel 

Applied, thanks for fixing this up.


Re: [PATCH v2 bpf-next 5/8] bpf: introduce BPF_RAW_TRACEPOINT

2018-03-23 Thread Alexei Starovoitov

On 3/23/18 5:58 PM, Alexei Starovoitov wrote:

On 3/23/18 4:13 PM, Daniel Borkmann wrote:

On 03/22/2018 04:41 PM, Alexei Starovoitov wrote:

On 3/22/18 2:43 AM, Daniel Borkmann wrote:

On 03/21/2018 07:54 PM, Alexei Starovoitov wrote:
[...]

@@ -546,6 +556,53 @@ extern void ftrace_profile_free_filter(struct
perf_event *event);
 void perf_trace_buf_update(void *record, u16 type);
 void *perf_trace_buf_alloc(int size, struct pt_regs **regs, int
*rctxp);

+void bpf_trace_run1(struct bpf_prog *prog, u64 arg1);
+void bpf_trace_run2(struct bpf_prog *prog, u64 arg1, u64 arg2);
+void bpf_trace_run3(struct bpf_prog *prog, u64 arg1, u64 arg2,
+u64 arg3);
+void bpf_trace_run4(struct bpf_prog *prog, u64 arg1, u64 arg2,
+u64 arg3, u64 arg4);
+void bpf_trace_run5(struct bpf_prog *prog, u64 arg1, u64 arg2,
+u64 arg3, u64 arg4, u64 arg5);
+void bpf_trace_run6(struct bpf_prog *prog, u64 arg1, u64 arg2,
+u64 arg3, u64 arg4, u64 arg5, u64 arg6);
+void bpf_trace_run7(struct bpf_prog *prog, u64 arg1, u64 arg2,
+u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7);
+void bpf_trace_run8(struct bpf_prog *prog, u64 arg1, u64 arg2,
+u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
+u64 arg8);
+void bpf_trace_run9(struct bpf_prog *prog, u64 arg1, u64 arg2,
+u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
+u64 arg8, u64 arg9);
+void bpf_trace_run10(struct bpf_prog *prog, u64 arg1, u64 arg2,
+ u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
+ u64 arg8, u64 arg9, u64 arg10);
+void bpf_trace_run11(struct bpf_prog *prog, u64 arg1, u64 arg2,
+ u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
+ u64 arg8, u64 arg9, u64 arg10, u64 arg11);
+void bpf_trace_run12(struct bpf_prog *prog, u64 arg1, u64 arg2,
+ u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
+ u64 arg8, u64 arg9, u64 arg10, u64 arg11, u64 arg12);
+void bpf_trace_run13(struct bpf_prog *prog, u64 arg1, u64 arg2,
+ u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
+ u64 arg8, u64 arg9, u64 arg10, u64 arg11, u64 arg12,
+ u64 arg13);
+void bpf_trace_run14(struct bpf_prog *prog, u64 arg1, u64 arg2,
+ u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
+ u64 arg8, u64 arg9, u64 arg10, u64 arg11, u64 arg12,
+ u64 arg13, u64 arg14);
+void bpf_trace_run15(struct bpf_prog *prog, u64 arg1, u64 arg2,
+ u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
+ u64 arg8, u64 arg9, u64 arg10, u64 arg11, u64 arg12,
+ u64 arg13, u64 arg14, u64 arg15);
+void bpf_trace_run16(struct bpf_prog *prog, u64 arg1, u64 arg2,
+ u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
+ u64 arg8, u64 arg9, u64 arg10, u64 arg11, u64 arg12,
+ u64 arg13, u64 arg14, u64 arg15, u64 arg16);
+void bpf_trace_run17(struct bpf_prog *prog, u64 arg1, u64 arg2,
+ u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
+ u64 arg8, u64 arg9, u64 arg10, u64 arg11, u64 arg12,
+ u64 arg13, u64 arg14, u64 arg15, u64 arg16, u64 arg17);
 void perf_trace_run_bpf_submit(void *raw_data, int size, int rctx,
struct trace_event_call *call, u64 count,
struct pt_regs *regs, struct hlist_head *head,

[...]

@@ -896,3 +976,206 @@ int perf_event_query_prog_array(struct
perf_event *event, void __user *info)

 return ret;
 }
+
+static __always_inline
+void __bpf_trace_run(struct bpf_prog *prog, u64 *args)
+{
+rcu_read_lock();
+preempt_disable();
+(void) BPF_PROG_RUN(prog, args);
+preempt_enable();
+rcu_read_unlock();
+}
+
+#define EVAL1(FN, X) FN(X)
+#define EVAL2(FN, X, Y...) FN(X) EVAL1(FN, Y)
+#define EVAL3(FN, X, Y...) FN(X) EVAL2(FN, Y)
+#define EVAL4(FN, X, Y...) FN(X) EVAL3(FN, Y)
+#define EVAL5(FN, X, Y...) FN(X) EVAL4(FN, Y)
+#define EVAL6(FN, X, Y...) FN(X) EVAL5(FN, Y)
+
+#define COPY(X) args[X - 1] = arg##X;
+
+void bpf_trace_run1(struct bpf_prog *prog, u64 arg1)
+{
+u64 args[1];
+
+EVAL1(COPY, 1);
+__bpf_trace_run(prog, args);
+}
+EXPORT_SYMBOL_GPL(bpf_trace_run1);
+void bpf_trace_run2(struct bpf_prog *prog, u64 arg1, u64 arg2)
+{
+u64 args[2];
+
+EVAL2(COPY, 1, 2);
+__bpf_trace_run(prog, args);
+}
+EXPORT_SYMBOL_GPL(bpf_trace_run2);
+void bpf_trace_run3(struct bpf_prog *prog, u64 arg1, u64 arg2,
+u64 arg3)
+{
+u64 args[3];
+
+EVAL3(COPY, 1, 2, 3);
+__bpf_trace_run(prog, args);
+}
+EXPORT_SYMBOL_GPL(bpf_trace_run3);
+void bpf_trace_run4(struct bpf_prog *prog, u64 arg1, u64 arg2,
+u64 arg3, u64 arg4)
+{
+u64 args[4];
+
+EVAL4(COPY, 1, 2, 3, 4);
+__bpf_trace_run(prog, args);
+}
+EXPORT_SYMBOL_GPL(bpf_trace_run4);
+void bpf_trace_run5(struct bpf_prog *prog, u64 arg1, u64 arg2,
+u64 arg3, u64 arg4, u64 arg5)
+{
+u64 args[5];
+
+EVAL5(COPY, 1, 

Re: [PATCH v2 bpf-next 5/8] bpf: introduce BPF_RAW_TRACEPOINT

2018-03-23 Thread Steven Rostedt
On Sat, 24 Mar 2018 00:13:28 +0100
Daniel Borkmann  wrote:

> #define UNPACK(...)   __VA_ARGS__
> #define REPEAT_1(FN, DL, X, ...)  FN(X)
> #define REPEAT_2(FN, DL, X, ...)  FN(X) UNPACK DL REPEAT_1(FN, DL, 
> __VA_ARGS__)
> #define REPEAT_3(FN, DL, X, ...)  FN(X) UNPACK DL REPEAT_2(FN, DL, 
> __VA_ARGS__)
> #define REPEAT_4(FN, DL, X, ...)  FN(X) UNPACK DL REPEAT_3(FN, DL, 
> __VA_ARGS__)
> #define REPEAT_5(FN, DL, X, ...)  FN(X) UNPACK DL REPEAT_4(FN, DL, 
> __VA_ARGS__)
> #define REPEAT_6(FN, DL, X, ...)  FN(X) UNPACK DL REPEAT_5(FN, DL, 
> __VA_ARGS__)
> #define REPEAT_7(FN, DL, X, ...)  FN(X) UNPACK DL REPEAT_6(FN, DL, 
> __VA_ARGS__)
> #define REPEAT_8(FN, DL, X, ...)  FN(X) UNPACK DL REPEAT_7(FN, DL, 
> __VA_ARGS__)
> #define REPEAT_9(FN, DL, X, ...)  FN(X) UNPACK DL REPEAT_8(FN, DL, 
> __VA_ARGS__)
> #define REPEAT(X, FN, DL, ...)REPEAT_##X(FN, DL, __VA_ARGS__)
> 
> #define SARG(X)   u64 arg##X
> #define COPY(X)   args[X] = arg##X
> 
> #define __DL_COM  (,)
> #define __DL_SEM  (;)
> 
> #define __SEQ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
> 
> #define BPF_TRACE_DECL_x(x)   \
>   void bpf_trace_run##x(struct bpf_prog *prog,\
> REPEAT(x, SARG, __DL_COM, __SEQ))
> #define BPF_TRACE_DEFN_x(x)   \
>   void bpf_trace_run##x(struct bpf_prog *prog,\
> REPEAT(x, SARG, __DL_COM, __SEQ)) \
>   {   \
>   u64 args[x];\
>   REPEAT(x, COPY, __DL_SEM, __SEQ);   \
>   __bpf_trace_run(prog, args);\
>   }   \
>   EXPORT_SYMBOL_GPL(bpf_trace_run##x)
> 
> So doing a ...
> 
> BPF_TRACE_DECL_x(5);
> BPF_TRACE_DEFN_x(5);
> 
> ... will generate in kernel/trace/bpf_trace.i:
> 
> void bpf_foo_trace_run5(struct bpf_prog *prog, u64 arg0 , u64 arg1 , u64 arg2 
> , u64 arg3 , u64 arg4);
> void bpf_foo_trace_run5(struct bpf_prog *prog, u64 arg0 , u64 arg1 , u64 arg2 
> , u64 arg3 , u64 arg4)
> {
>   u64 args[5];
>   args[0] = arg0 ;
>   args[1] = arg1 ;
>   args[2] = arg2 ;
>   args[3] = arg3 ;
>   args[4] = arg4;
>   __bpf_trace_run(prog, args);
> } [...]
> 
> Meaning, the EVALx() macros could be removed from there, too. Potentially, the
> REPEAT() macro could sit in its own include/linux/ header for others to reuse
> or such.

And people think my macro magic in include/trace/ftrace_event.h is
funky. Now I know who stole my MACRO MAGIC HAT.

-- Steve


Re: [PATCH v2 bpf-next 5/8] bpf: introduce BPF_RAW_TRACEPOINT

2018-03-23 Thread Alexei Starovoitov

On 3/23/18 4:13 PM, Daniel Borkmann wrote:

On 03/22/2018 04:41 PM, Alexei Starovoitov wrote:

On 3/22/18 2:43 AM, Daniel Borkmann wrote:

On 03/21/2018 07:54 PM, Alexei Starovoitov wrote:
[...]

@@ -546,6 +556,53 @@ extern void ftrace_profile_free_filter(struct perf_event 
*event);
 void perf_trace_buf_update(void *record, u16 type);
 void *perf_trace_buf_alloc(int size, struct pt_regs **regs, int *rctxp);

+void bpf_trace_run1(struct bpf_prog *prog, u64 arg1);
+void bpf_trace_run2(struct bpf_prog *prog, u64 arg1, u64 arg2);
+void bpf_trace_run3(struct bpf_prog *prog, u64 arg1, u64 arg2,
+u64 arg3);
+void bpf_trace_run4(struct bpf_prog *prog, u64 arg1, u64 arg2,
+u64 arg3, u64 arg4);
+void bpf_trace_run5(struct bpf_prog *prog, u64 arg1, u64 arg2,
+u64 arg3, u64 arg4, u64 arg5);
+void bpf_trace_run6(struct bpf_prog *prog, u64 arg1, u64 arg2,
+u64 arg3, u64 arg4, u64 arg5, u64 arg6);
+void bpf_trace_run7(struct bpf_prog *prog, u64 arg1, u64 arg2,
+u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7);
+void bpf_trace_run8(struct bpf_prog *prog, u64 arg1, u64 arg2,
+u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
+u64 arg8);
+void bpf_trace_run9(struct bpf_prog *prog, u64 arg1, u64 arg2,
+u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
+u64 arg8, u64 arg9);
+void bpf_trace_run10(struct bpf_prog *prog, u64 arg1, u64 arg2,
+ u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
+ u64 arg8, u64 arg9, u64 arg10);
+void bpf_trace_run11(struct bpf_prog *prog, u64 arg1, u64 arg2,
+ u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
+ u64 arg8, u64 arg9, u64 arg10, u64 arg11);
+void bpf_trace_run12(struct bpf_prog *prog, u64 arg1, u64 arg2,
+ u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
+ u64 arg8, u64 arg9, u64 arg10, u64 arg11, u64 arg12);
+void bpf_trace_run13(struct bpf_prog *prog, u64 arg1, u64 arg2,
+ u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
+ u64 arg8, u64 arg9, u64 arg10, u64 arg11, u64 arg12,
+ u64 arg13);
+void bpf_trace_run14(struct bpf_prog *prog, u64 arg1, u64 arg2,
+ u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
+ u64 arg8, u64 arg9, u64 arg10, u64 arg11, u64 arg12,
+ u64 arg13, u64 arg14);
+void bpf_trace_run15(struct bpf_prog *prog, u64 arg1, u64 arg2,
+ u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
+ u64 arg8, u64 arg9, u64 arg10, u64 arg11, u64 arg12,
+ u64 arg13, u64 arg14, u64 arg15);
+void bpf_trace_run16(struct bpf_prog *prog, u64 arg1, u64 arg2,
+ u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
+ u64 arg8, u64 arg9, u64 arg10, u64 arg11, u64 arg12,
+ u64 arg13, u64 arg14, u64 arg15, u64 arg16);
+void bpf_trace_run17(struct bpf_prog *prog, u64 arg1, u64 arg2,
+ u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
+ u64 arg8, u64 arg9, u64 arg10, u64 arg11, u64 arg12,
+ u64 arg13, u64 arg14, u64 arg15, u64 arg16, u64 arg17);
 void perf_trace_run_bpf_submit(void *raw_data, int size, int rctx,
struct trace_event_call *call, u64 count,
struct pt_regs *regs, struct hlist_head *head,

[...]

@@ -896,3 +976,206 @@ int perf_event_query_prog_array(struct perf_event *event, 
void __user *info)

 return ret;
 }
+
+static __always_inline
+void __bpf_trace_run(struct bpf_prog *prog, u64 *args)
+{
+rcu_read_lock();
+preempt_disable();
+(void) BPF_PROG_RUN(prog, args);
+preempt_enable();
+rcu_read_unlock();
+}
+
+#define EVAL1(FN, X) FN(X)
+#define EVAL2(FN, X, Y...) FN(X) EVAL1(FN, Y)
+#define EVAL3(FN, X, Y...) FN(X) EVAL2(FN, Y)
+#define EVAL4(FN, X, Y...) FN(X) EVAL3(FN, Y)
+#define EVAL5(FN, X, Y...) FN(X) EVAL4(FN, Y)
+#define EVAL6(FN, X, Y...) FN(X) EVAL5(FN, Y)
+
+#define COPY(X) args[X - 1] = arg##X;
+
+void bpf_trace_run1(struct bpf_prog *prog, u64 arg1)
+{
+u64 args[1];
+
+EVAL1(COPY, 1);
+__bpf_trace_run(prog, args);
+}
+EXPORT_SYMBOL_GPL(bpf_trace_run1);
+void bpf_trace_run2(struct bpf_prog *prog, u64 arg1, u64 arg2)
+{
+u64 args[2];
+
+EVAL2(COPY, 1, 2);
+__bpf_trace_run(prog, args);
+}
+EXPORT_SYMBOL_GPL(bpf_trace_run2);
+void bpf_trace_run3(struct bpf_prog *prog, u64 arg1, u64 arg2,
+u64 arg3)
+{
+u64 args[3];
+
+EVAL3(COPY, 1, 2, 3);
+__bpf_trace_run(prog, args);
+}
+EXPORT_SYMBOL_GPL(bpf_trace_run3);
+void bpf_trace_run4(struct bpf_prog *prog, u64 arg1, u64 arg2,
+u64 arg3, u64 arg4)
+{
+u64 args[4];
+
+EVAL4(COPY, 1, 2, 3, 4);
+__bpf_trace_run(prog, args);
+}
+EXPORT_SYMBOL_GPL(bpf_trace_run4);
+void bpf_trace_run5(struct bpf_prog *prog, u64 arg1, u64 arg2,
+u64 arg3, u64 arg4, u64 arg5)
+{
+u64 args[5];
+
+EVAL5(COPY, 1, 2, 3, 4, 5);
+__bpf_trace_run(prog, 

[PATCH net-next 07/13] liquidio: Removed netif_is_multiqueue check

2018-03-23 Thread Felix Manlunas
From: Intiyaz Basha 

Removing checks for netif_is_multiqueue.
Configuring single queue will be a multiqueue netdev with one queues.

Signed-off-by: Intiyaz Basha 
Acked-by: Derek Chickles 
Signed-off-by: Felix Manlunas 
---
 drivers/net/ethernet/cavium/liquidio/lio_core.c| 18 ++---
 drivers/net/ethernet/cavium/liquidio/lio_main.c| 93 +++---
 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c | 55 -
 .../net/ethernet/cavium/liquidio/octeon_network.h  | 50 
 4 files changed, 64 insertions(+), 152 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_core.c 
b/drivers/net/ethernet/cavium/liquidio/lio_core.c
index 666cf7e..73e70e0 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_core.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_core.c
@@ -377,20 +377,12 @@ static void lio_update_txq_status(struct octeon_device 
*oct, int iq_num)
return;
 
lio = GET_LIO(netdev);
-   if (netif_is_multiqueue(netdev)) {
-   if (__netif_subqueue_stopped(netdev, iq->q_index) &&
-   lio->linfo.link.s.link_up &&
-   (!octnet_iq_is_full(oct, iq_num))) {
-   netif_wake_subqueue(netdev, iq->q_index);
-   INCR_INSTRQUEUE_PKT_COUNT(lio->oct_dev, iq_num,
- tx_restart, 1);
-   }
-   } else if (netif_queue_stopped(netdev) &&
-  lio->linfo.link.s.link_up &&
-  (!octnet_iq_is_full(oct, lio->txq))) {
-   INCR_INSTRQUEUE_PKT_COUNT(lio->oct_dev, lio->txq,
+   if (__netif_subqueue_stopped(netdev, iq->q_index) &&
+   lio->linfo.link.s.link_up &&
+   (!octnet_iq_is_full(oct, iq_num))) {
+   netif_wake_subqueue(netdev, iq->q_index);
+   INCR_INSTRQUEUE_PKT_COUNT(lio->oct_dev, iq_num,
  tx_restart, 1);
-   netif_wake_queue(netdev);
}
 }
 
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 41e992c..5ef9aa0 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -515,10 +515,7 @@ static void liquidio_deinit_pci(void)
  */
 static inline void wake_q(struct net_device *netdev, int q)
 {
-   if (netif_is_multiqueue(netdev))
-   netif_wake_subqueue(netdev, q);
-   else
-   netif_wake_queue(netdev);
+   netif_wake_subqueue(netdev, q);
 }
 
 /**
@@ -528,10 +525,7 @@ static inline void wake_q(struct net_device *netdev, int q)
  */
 static inline void stop_q(struct net_device *netdev, int q)
 {
-   if (netif_is_multiqueue(netdev))
-   netif_stop_subqueue(netdev, q);
-   else
-   netif_stop_queue(netdev);
+   netif_stop_subqueue(netdev, q);
 }
 
 /**
@@ -541,33 +535,24 @@ static inline void stop_q(struct net_device *netdev, int 
q)
  */
 static inline int check_txq_status(struct lio *lio)
 {
+   int numqs = lio->netdev->num_tx_queues;
int ret_val = 0;
+   int q, iq;
 
-   if (netif_is_multiqueue(lio->netdev)) {
-   int numqs = lio->netdev->num_tx_queues;
-   int q, iq = 0;
-
-   /* check each sub-queue state */
-   for (q = 0; q < numqs; q++) {
-   iq = lio->linfo.txpciq[q %
-   lio->oct_dev->num_iqs].s.q_no;
-   if (octnet_iq_is_full(lio->oct_dev, iq))
-   continue;
-   if (__netif_subqueue_stopped(lio->netdev, q)) {
-   wake_q(lio->netdev, q);
-   INCR_INSTRQUEUE_PKT_COUNT(lio->oct_dev, iq,
- tx_restart, 1);
-   ret_val++;
-   }
+   /* check each sub-queue state */
+   for (q = 0; q < numqs; q++) {
+   iq = lio->linfo.txpciq[q %
+   lio->oct_dev->num_iqs].s.q_no;
+   if (octnet_iq_is_full(lio->oct_dev, iq))
+   continue;
+   if (__netif_subqueue_stopped(lio->netdev, q)) {
+   wake_q(lio->netdev, q);
+   INCR_INSTRQUEUE_PKT_COUNT(lio->oct_dev, iq,
+ tx_restart, 1);
+   ret_val++;
}
-   } else {
-   if (octnet_iq_is_full(lio->oct_dev, lio->txq))
-   return 0;
-   wake_q(lio->netdev, lio->txq);
-   INCR_INSTRQUEUE_PKT_COUNT(lio->oct_dev, lio->txq,
- tx_restart, 1);
-   ret_val = 1;
}
+
return ret_val;
 }
 

[PATCH net-next 09/13] liquidio: Removed one line function wake_q

2018-03-23 Thread Felix Manlunas
From: Intiyaz Basha 

Removing one line function wake_q

Signed-off-by: Intiyaz Basha 
Acked-by: Derek Chickles 
Signed-off-by: Felix Manlunas 
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c| 14 ++
 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c | 12 +---
 2 files changed, 3 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index be16a1c..78f6794 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -509,16 +509,6 @@ static void liquidio_deinit_pci(void)
 }
 
 /**
- * \brief Wake a queue
- * @param netdev network device
- * @param q which queue to wake
- */
-static inline void wake_q(struct net_device *netdev, int q)
-{
-   netif_wake_subqueue(netdev, q);
-}
-
-/**
  * \brief Check Tx queue status, and take appropriate action
  * @param lio per-network private data
  * @returns 0 if full, number of queues woken up otherwise
@@ -536,7 +526,7 @@ static inline int check_txq_status(struct lio *lio)
if (octnet_iq_is_full(lio->oct_dev, iq))
continue;
if (__netif_subqueue_stopped(lio->netdev, q)) {
-   wake_q(lio->netdev, q);
+   netif_wake_subqueue(lio->netdev, q);
INCR_INSTRQUEUE_PKT_COUNT(lio->oct_dev, iq,
  tx_restart, 1);
ret_val++;
@@ -1656,7 +1646,7 @@ static inline int check_txq_state(struct lio *lio, struct 
sk_buff *skb)
 
if (__netif_subqueue_stopped(lio->netdev, q)) {
INCR_INSTRQUEUE_PKT_COUNT(lio->oct_dev, iq, tx_restart, 1);
-   wake_q(lio->netdev, q);
+   netif_wake_subqueue(lio->netdev, q);
}
return 1;
 }
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
index 3120aed..5ab0831 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
@@ -285,16 +285,6 @@ static pci_ers_result_t 
liquidio_pcie_error_detected(struct pci_dev *pdev,
 };
 
 /**
- * \brief Wake a queue
- * @param netdev network device
- * @param q which queue to wake
- */
-static void wake_q(struct net_device *netdev, int q)
-{
-   netif_wake_subqueue(netdev, q);
-}
-
-/**
  * Remove the node at the head of the list. The list would be empty at
  * the end of this call if there are no more nodes in the list.
  */
@@ -980,7 +970,7 @@ static int check_txq_state(struct lio *lio, struct sk_buff 
*skb)
 
if (__netif_subqueue_stopped(lio->netdev, q)) {
INCR_INSTRQUEUE_PKT_COUNT(lio->oct_dev, iq, tx_restart, 1);
-   wake_q(lio->netdev, q);
+   netif_wake_subqueue(lio->netdev, q);
}
 
return 1;
-- 
1.8.3.1



[PATCH net-next 13/13] liquidio: Renamed txqs_start to start_txqs

2018-03-23 Thread Felix Manlunas
From: Intiyaz Basha 

For consistency renaming txqs_start to start_txqs

Signed-off-by: Intiyaz Basha 
Acked-by: Derek Chickles 
Signed-off-by: Felix Manlunas 
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c   | 2 +-
 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c| 2 +-
 drivers/net/ethernet/cavium/liquidio/octeon_network.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 54fd315..ba3ca02 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -2086,7 +2086,7 @@ static int liquidio_open(struct net_device *netdev)
return -1;
}
 
-   txqs_start(netdev);
+   start_txqs(netdev);
 
/* tell Octeon to start forwarding packets to host */
send_rx_ctrl_cmd(lio, 1);
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
index 4d7a0ae..d5f5c9a 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
@@ -1144,7 +1144,7 @@ static int liquidio_open(struct net_device *netdev)
lio->intf_open = 1;
 
netif_info(lio, ifup, lio->netdev, "Interface Open, ready for 
traffic\n");
-   txqs_start(netdev);
+   start_txqs(netdev);
 
/* tell Octeon to start forwarding packets to host */
send_rx_ctrl_cmd(lio, 1);
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_network.h 
b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
index 1b4c85a..8782206 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_network.h
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
@@ -542,7 +542,7 @@ static inline void wake_txqs(struct net_device *netdev)
  * \brief Start Tx queues
  * @param netdev network device
  */
-static inline void txqs_start(struct net_device *netdev)
+static inline void start_txqs(struct net_device *netdev)
 {
struct lio *lio = GET_LIO(netdev);
int i;
-- 
1.8.3.1



Re: [RFC v3 net-next 13/18] net/sched: Introduce the TBS Qdisc

2018-03-23 Thread Jesus Sanchez-Palencia
Hi,


On 03/22/2018 03:52 PM, Thomas Gleixner wrote:
> On Thu, 22 Mar 2018, Jesus Sanchez-Palencia wrote:
>> Our plan was to work directly with the Qbv-like scheduling (per-port) just 
>> after
>> the cbs qdisc (Qav), but the feedback here and offline was that there were 
>> use
>> cases for a more simplistic launchtime approach (per-queue) as well. We've
>> decided to invest on it first (and postpone the 'taprio' qdisc until there 
>> was
>> NIC available with HW support for it, basically).
> 
> I missed that discussion due to other urgent stuff on my plate. Just
> skimmed through it. More below.
> 
>> You are right, and we agree, that using tbs for a per-port schedule of any 
>> sort
>> will require a SW scheduler to be developed on top of it, but we've never 
>> said
>> the contrary either. Our vision has always been that these are separate
>> mechanisms with different use-cases, so we do see the value for the kernel to
>> provide both.
>>
>> In other words, tbs is not the final solution for Qbv, and we agree that a 
>> 'TAS'
>> qdisc is still necessary. And due to the wide range of applications and hw 
>> being
>> used for those out there, we need both specially given that one does not 
>> block
>> the other.
> 
> So what's the plan for this? Having TAS as a separate entity or TAS feeding
> into the proposed 'basic' time transmission thing?


The second one, I guess. Elaborating, the plan is at some point having TAS as a
separate entity, but which can use tbs for one of its classes (and cbs for
another, and strict priority for everything else, etc).

Basically, the design would something along the lines of 'taprio'. A root qdisc
that is both time and priority aware, and capable of running a schedule for the
port. That schedule can run inside the kernel with hrtimers, or just be
offloaded into the controller if Qbv is supported on HW.

Because it would expose the inner traffic classes in a mq / mqprio / prio style,
then it would allow for other per-queue qdiscs to be attached to it. On a system
using the i210, for instance, we could then have tbs installed on traffic class
0 just dialing hw offload. The Qbv schedule would be running in SW on the TAS
entity (i.e. 'taprio') which would be setting the packets' txtime before
dequeueing packets on a fast path -> tbs -> NIC.

Similarly, other qdisc, like cbs, could be installed if all that traffic class
requires is traffic shaping once its 'gate' is allowed to execute the selected
tx algorithm attached to it.



> 
> The general objection I have with the current approach is that it creates
> the playground for all flavours of misdesigned user space implementations
> and just replaces the home brewn and ugly user mode network adapter
> drivers.
> 
> But that's not helping the cause at all. There is enough crappy stuff out
> there already and I rather see a proper designed slice management which can
> be utilized and improved by all involved parties.
> 
> All variants which utilize the basic time driven packet transmission are
> based on periodic explicit plan scheduling with (local) network wide time
> slice assignment.
> 
> It does not matter whether you feed VLAN traffic into a time slice, where
> the VLAN itself does not even have to know about it, or if you have aware
> applications feeding packets to a designated timeslot. The basic principle
> of this is always the same.
> 
> So coming back to last years discussion. It totally went into the wrong
> direction because it turned from an approach (the patches) which came from
> the big picture to an single use case and application centric view. That's
> just wrong and I regret that I didn't have the time to pay attention back
> then.
> 
> You always need to look at the big picture first and design from there, not
> the other way round. There will always be the argument:
> 
> But my application is special and needs X
> 
> It's easy to fall for that. From a long experience I know that none of
> these claims ever held. These arguments are made because the people making
> them have either never looked at the big picture or are simply refusing to
> do so because it would cause them work.
> 
> If you start from the use case and application centric view and ignore the
> big picture then you end up in a gazillion of extra magic features over
> time which could have been completely avoided if you had put your foot down
> and made everyone to agree on a proper and versatile design in the first
> place.
> 
> The more low level access you hand out in the beginning the less commonly
> used, improved and maintained infrastrucure you will get in the end. That
> has happened before in other areas and it will happen here as well. You
> create a user space ABI which you cant get rid off and before you come out
> with the proper interface after that a large number of involved parties
> have gone off and implemented on top of the low level ABI and they will
> never look back.
> 
> In the (not so) long run this will create 

[PATCH net-next 11/13] liquidio: Renamed txqs_wake to wake_txqs

2018-03-23 Thread Felix Manlunas
From: Intiyaz Basha 

For consistency renaming txqs_wake to wake_txqs

Signed-off-by: Intiyaz Basha 
Acked-by: Derek Chickles 
Signed-off-by: Felix Manlunas 
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c   | 4 ++--
 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c| 4 ++--
 drivers/net/ethernet/cavium/liquidio/octeon_network.h | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 2558a94..8b0a080 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -777,7 +777,7 @@ static inline void update_link_status(struct net_device 
*netdev,
if (lio->linfo.link.s.link_up) {
dev_dbg(>pci_dev->dev, "%s: link_up", __func__);
netif_carrier_on(netdev);
-   txqs_wake(netdev);
+   wake_txqs(netdev);
} else {
dev_dbg(>pci_dev->dev, "%s: link_off", __func__);
netif_carrier_off(netdev);
@@ -2763,7 +2763,7 @@ static void liquidio_tx_timeout(struct net_device *netdev)
   "Transmit timeout tx_dropped:%ld, waking up queues now!!\n",
   netdev->stats.tx_dropped);
netif_trans_update(netdev);
-   txqs_wake(netdev);
+   wake_txqs(netdev);
 }
 
 static int liquidio_vlan_rx_add_vid(struct net_device *netdev,
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
index 478c20a..288096b 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
@@ -515,7 +515,7 @@ static void update_link_status(struct net_device *netdev,
 
if (lio->linfo.link.s.link_up) {
netif_carrier_on(netdev);
-   txqs_wake(netdev);
+   wake_txqs(netdev);
} else {
netif_carrier_off(netdev);
txqs_stop(netdev);
@@ -1822,7 +1822,7 @@ static void liquidio_tx_timeout(struct net_device *netdev)
   "Transmit timeout tx_dropped:%ld, waking up queues now!!\n",
   netdev->stats.tx_dropped);
netif_trans_update(netdev);
-   txqs_wake(netdev);
+   wake_txqs(netdev);
 }
 
 static int
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_network.h 
b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
index 7922a69..3cbc65a 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_network.h
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
@@ -522,7 +522,7 @@ static inline void txqs_stop(struct net_device *netdev)
  * \brief Wake Tx queues
  * @param netdev network device
  */
-static inline void txqs_wake(struct net_device *netdev)
+static inline void wake_txqs(struct net_device *netdev)
 {
struct lio *lio = GET_LIO(netdev);
int i, qno;
-- 
1.8.3.1



[PATCH net-next 06/13] liquidio: Removed start_txq function

2018-03-23 Thread Felix Manlunas
From: Intiyaz Basha 

Removing start_txq function from VF and PF files

Signed-off-by: Intiyaz Basha 
Acked-by: Derek Chickles 
Signed-off-by: Felix Manlunas 
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c   | 16 +---
 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c| 16 +---
 drivers/net/ethernet/cavium/liquidio/octeon_network.h | 16 ++--
 3 files changed, 12 insertions(+), 36 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 6b44d44..41e992c 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -509,20 +509,6 @@ static void liquidio_deinit_pci(void)
 }
 
 /**
- * \brief Start Tx queue
- * @param netdev network device
- */
-static void start_txq(struct net_device *netdev)
-{
-   struct lio *lio = GET_LIO(netdev);
-
-   if (lio->linfo.link.s.link_up) {
-   txqs_start(netdev);
-   return;
-   }
-}
-
-/**
  * \brief Wake a queue
  * @param netdev network device
  * @param q which queue to wake
@@ -2140,7 +2126,7 @@ static int liquidio_open(struct net_device *netdev)
return -1;
}
 
-   start_txq(netdev);
+   txqs_start(netdev);
 
/* tell Octeon to start forwarding packets to host */
send_rx_ctrl_cmd(lio, 1);
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
index 5f0114d..57b6ee5 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
@@ -285,20 +285,6 @@ static pci_ers_result_t 
liquidio_pcie_error_detected(struct pci_dev *pdev,
 };
 
 /**
- * \brief Start Tx queue
- * @param netdev network device
- */
-static void start_txq(struct net_device *netdev)
-{
-   struct lio *lio = GET_LIO(netdev);
-
-   if (lio->linfo.link.s.link_up) {
-   txqs_start(netdev);
-   return;
-   }
-}
-
-/**
  * \brief Wake a queue
  * @param netdev network device
  * @param q which queue to wake
@@ -1189,7 +1175,7 @@ static int liquidio_open(struct net_device *netdev)
lio->intf_open = 1;
 
netif_info(lio, ifup, lio->netdev, "Interface Open, ready for 
traffic\n");
-   start_txq(netdev);
+   txqs_start(netdev);
 
/* tell Octeon to start forwarding packets to host */
send_rx_ctrl_cmd(lio, 1);
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_network.h 
b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
index cd334a7..72a581a 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_network.h
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
@@ -556,13 +556,17 @@ static inline void txqs_wake(struct net_device *netdev)
  */
 static inline void txqs_start(struct net_device *netdev)
 {
-   if (netif_is_multiqueue(netdev)) {
-   int i;
+   struct lio *lio = GET_LIO(netdev);
 
-   for (i = 0; i < netdev->num_tx_queues; i++)
-   netif_start_subqueue(netdev, i);
-   } else {
-   netif_start_queue(netdev);
+   if (lio->linfo.link.s.link_up) {
+   if (netif_is_multiqueue(netdev)) {
+   int i;
+
+   for (i = 0; i < netdev->num_tx_queues; i++)
+   netif_start_subqueue(netdev, i);
+   } else {
+   netif_start_queue(netdev);
+   }
}
 }
 
-- 
1.8.3.1



[PATCH net-next 08/13] liquidio: Removed one line function stop_q

2018-03-23 Thread Felix Manlunas
From: Intiyaz Basha 

Removing one line function stop_q

Signed-off-by: Intiyaz Basha 
Acked-by: Derek Chickles 
Signed-off-by: Felix Manlunas 
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c| 12 +---
 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c | 12 +---
 2 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 5ef9aa0..be16a1c 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -519,16 +519,6 @@ static inline void wake_q(struct net_device *netdev, int q)
 }
 
 /**
- * \brief Stop a queue
- * @param netdev network device
- * @param q which queue to stop
- */
-static inline void stop_q(struct net_device *netdev, int q)
-{
-   netif_stop_subqueue(netdev, q);
-}
-
-/**
  * \brief Check Tx queue status, and take appropriate action
  * @param lio per-network private data
  * @returns 0 if full, number of queues woken up otherwise
@@ -2745,7 +2735,7 @@ static int liquidio_xmit(struct sk_buff *skb, struct 
net_device *netdev)
netif_info(lio, tx_queued, lio->netdev, "Transmit queued 
successfully\n");
 
if (status == IQ_SEND_STOP)
-   stop_q(netdev, q_idx);
+   netif_stop_subqueue(netdev, q_idx);
 
netif_trans_update(netdev);
 
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
index f46289d..3120aed 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
@@ -295,16 +295,6 @@ static void wake_q(struct net_device *netdev, int q)
 }
 
 /**
- * \brief Stop a queue
- * @param netdev network device
- * @param q which queue to stop
- */
-static void stop_q(struct net_device *netdev, int q)
-{
-   netif_stop_subqueue(netdev, q);
-}
-
-/**
  * Remove the node at the head of the list. The list would be empty at
  * the end of this call if there are no more nodes in the list.
  */
@@ -1803,7 +1793,7 @@ static int liquidio_xmit(struct sk_buff *skb, struct 
net_device *netdev)
if (status == IQ_SEND_STOP) {
dev_err(>pci_dev->dev, "Rcvd IQ_SEND_STOP signal; stopping 
IQ-%d\n",
iq_no);
-   stop_q(netdev, q_idx);
+   netif_stop_subqueue(netdev, q_idx);
}
 
netif_trans_update(netdev);
-- 
1.8.3.1



[PATCH net-next 04/13] liquidio: Moved common function skb_iq to to octeon_network.h

2018-03-23 Thread Felix Manlunas
From: Intiyaz Basha 

Moving common function skb_iq to to octeon_network.h

Signed-off-by: Intiyaz Basha 
Acked-by: Derek Chickles 
Signed-off-by: Felix Manlunas 
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c   | 10 --
 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c| 10 --
 drivers/net/ethernet/cavium/liquidio/octeon_network.h | 10 ++
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 8e280c5..ec7c403 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -1687,16 +1687,6 @@ static int octeon_pci_os_setup(struct octeon_device *oct)
return 0;
 }
 
-static inline int skb_iq(struct lio *lio, struct sk_buff *skb)
-{
-   int q = 0;
-
-   if (netif_is_multiqueue(lio->netdev))
-   q = skb->queue_mapping % lio->linfo.num_txpciq;
-
-   return q;
-}
-
 /**
  * \brief Check Tx queue state for a given network buffer
  * @param lio per-network private data
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
index 82d70e4..5f0114d 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
@@ -993,16 +993,6 @@ static int octeon_pci_os_setup(struct octeon_device *oct)
return 0;
 }
 
-static int skb_iq(struct lio *lio, struct sk_buff *skb)
-{
-   int q = 0;
-
-   if (netif_is_multiqueue(lio->netdev))
-   q = skb->queue_mapping % lio->linfo.num_txpciq;
-
-   return q;
-}
-
 /**
  * \brief Check Tx queue state for a given network buffer
  * @param lio per-network private data
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_network.h 
b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
index 0a14d77..cd334a7 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_network.h
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
@@ -566,4 +566,14 @@ static inline void txqs_start(struct net_device *netdev)
}
 }
 
+static inline int skb_iq(struct lio *lio, struct sk_buff *skb)
+{
+   int q = 0;
+
+   if (netif_is_multiqueue(lio->netdev))
+   q = skb->queue_mapping % lio->linfo.num_txpciq;
+
+   return q;
+}
+
 #endif
-- 
1.8.3.1



[PATCH net-next 10/13] liquidio: Function call skb_iq for deriving queue from skb

2018-03-23 Thread Felix Manlunas
From: Intiyaz Basha 

Using skb_iq function for deriving queue from skb

Signed-off-by: Intiyaz Basha 
Acked-by: Derek Chickles 
Signed-off-by: Felix Manlunas 
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c| 3 +--
 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 78f6794..2558a94 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -2528,8 +2528,7 @@ static int liquidio_xmit(struct sk_buff *skb, struct 
net_device *netdev)
lio = GET_LIO(netdev);
oct = lio->oct_dev;
 
-   q_idx = skb->queue_mapping;
-   q_idx = (q_idx % (lio->linfo.num_txpciq));
+   q_idx = skb_iq(lio, skb);
tag = q_idx;
iq_no = lio->linfo.txpciq[q_idx].s.q_no;
 
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
index 5ab0831..478c20a 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
@@ -1604,8 +1604,7 @@ static int liquidio_xmit(struct sk_buff *skb, struct 
net_device *netdev)
lio = GET_LIO(netdev);
oct = lio->oct_dev;
 
-   q_idx = skb->queue_mapping;
-   q_idx = (q_idx % (lio->linfo.num_txpciq));
+   q_idx = skb_iq(lio, skb);
tag = q_idx;
iq_no = lio->linfo.txpciq[q_idx].s.q_no;
 
-- 
1.8.3.1



[PATCH net-next 12/13] liquidio: Renamed txqs_stop to stop_txqs

2018-03-23 Thread Felix Manlunas
From: Intiyaz Basha 

For consistency renaming txqs_stop to stop_txqs

Signed-off-by: Intiyaz Basha 
Acked-by: Derek Chickles 
Signed-off-by: Felix Manlunas 
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c   | 2 +-
 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c| 4 ++--
 drivers/net/ethernet/cavium/liquidio/octeon_network.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 8b0a080..54fd315 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -781,7 +781,7 @@ static inline void update_link_status(struct net_device 
*netdev,
} else {
dev_dbg(>pci_dev->dev, "%s: link_off", __func__);
netif_carrier_off(netdev);
-   txqs_stop(netdev);
+   stop_txqs(netdev);
}
if (lio->linfo.link.s.mtu != current_max_mtu) {
netif_info(lio, probe, lio->netdev, "Max MTU changed 
from %d to %d\n",
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
index 288096b..4d7a0ae 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
@@ -518,7 +518,7 @@ static void update_link_status(struct net_device *netdev,
wake_txqs(netdev);
} else {
netif_carrier_off(netdev);
-   txqs_stop(netdev);
+   stop_txqs(netdev);
}
 
if (lio->linfo.link.s.mtu != current_max_mtu) {
@@ -1186,7 +1186,7 @@ static int liquidio_stop(struct net_device *netdev)
 
ifstate_reset(lio, LIO_IFSTATE_RUNNING);
 
-   txqs_stop(netdev);
+   stop_txqs(netdev);
 
dev_info(>pci_dev->dev, "%s interface is stopped\n", netdev->name);
 
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_network.h 
b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
index 3cbc65a..1b4c85a 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_network.h
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
@@ -510,7 +510,7 @@ static inline int wait_for_pending_requests(struct 
octeon_device *oct)
  * \brief Stop Tx queues
  * @param netdev network device
  */
-static inline void txqs_stop(struct net_device *netdev)
+static inline void stop_txqs(struct net_device *netdev)
 {
int i;
 
-- 
1.8.3.1



[PATCH net-next 05/13] liquidio: Removed one line function stop_txq

2018-03-23 Thread Felix Manlunas
From: Intiyaz Basha 

Removing one line function stop_txq

Signed-off-by: Intiyaz Basha 
Acked-by: Derek Chickles 
Signed-off-by: Felix Manlunas 
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c | 11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index ec7c403..6b44d44 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -509,15 +509,6 @@ static void liquidio_deinit_pci(void)
 }
 
 /**
- * \brief Stop Tx queue
- * @param netdev network device
- */
-static void stop_txq(struct net_device *netdev)
-{
-   txqs_stop(netdev);
-}
-
-/**
  * \brief Start Tx queue
  * @param netdev network device
  */
@@ -839,7 +830,7 @@ static inline void update_link_status(struct net_device 
*netdev,
} else {
dev_dbg(>pci_dev->dev, "%s: link_off", __func__);
netif_carrier_off(netdev);
-   stop_txq(netdev);
+   txqs_stop(netdev);
}
if (lio->linfo.link.s.mtu != current_max_mtu) {
netif_info(lio, probe, lio->netdev, "Max MTU changed 
from %d to %d\n",
-- 
1.8.3.1



[PATCH net-next 03/13] liquidio: Moved common function txqs_start to octeon_network.h

2018-03-23 Thread Felix Manlunas
From: Intiyaz Basha 

Moving common function txqs_start to octeon_network.h

Signed-off-by: Intiyaz Basha 
Acked-by: Derek Chickles 
Signed-off-by: Felix Manlunas 
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c   | 16 
 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c| 16 
 drivers/net/ethernet/cavium/liquidio/octeon_network.h | 17 +
 3 files changed, 17 insertions(+), 32 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 089f494..8e280c5 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -509,22 +509,6 @@ static void liquidio_deinit_pci(void)
 }
 
 /**
- * \brief Start Tx queues
- * @param netdev network device
- */
-static inline void txqs_start(struct net_device *netdev)
-{
-   if (netif_is_multiqueue(netdev)) {
-   int i;
-
-   for (i = 0; i < netdev->num_tx_queues; i++)
-   netif_start_subqueue(netdev, i);
-   } else {
-   netif_start_queue(netdev);
-   }
-}
-
-/**
  * \brief Stop Tx queue
  * @param netdev network device
  */
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
index 60743c3..82d70e4 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
@@ -285,22 +285,6 @@ static pci_ers_result_t 
liquidio_pcie_error_detected(struct pci_dev *pdev,
 };
 
 /**
- * \brief Start Tx queues
- * @param netdev network device
- */
-static void txqs_start(struct net_device *netdev)
-{
-   if (netif_is_multiqueue(netdev)) {
-   int i;
-
-   for (i = 0; i < netdev->num_tx_queues; i++)
-   netif_start_subqueue(netdev, i);
-   } else {
-   netif_start_queue(netdev);
-   }
-}
-
-/**
  * \brief Start Tx queue
  * @param netdev network device
  */
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_network.h 
b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
index 2d2f49b..0a14d77 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_network.h
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
@@ -549,4 +549,21 @@ static inline void txqs_wake(struct net_device *netdev)
netif_wake_queue(netdev);
}
 }
+
+/**
+ * \brief Start Tx queues
+ * @param netdev network device
+ */
+static inline void txqs_start(struct net_device *netdev)
+{
+   if (netif_is_multiqueue(netdev)) {
+   int i;
+
+   for (i = 0; i < netdev->num_tx_queues; i++)
+   netif_start_subqueue(netdev, i);
+   } else {
+   netif_start_queue(netdev);
+   }
+}
+
 #endif
-- 
1.8.3.1



[PATCH net-next 02/13] liquidio: Moved common function txqs_wake to octeon_network.h

2018-03-23 Thread Felix Manlunas
From: Intiyaz Basha 

Moving common function txqs_wake to octeon_network.h

Signed-off-by: Intiyaz Basha 
Acked-by: Derek Chickles 
Signed-off-by: Felix Manlunas 
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c| 28 --
 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c | 27 -
 .../net/ethernet/cavium/liquidio/octeon_network.h  | 27 +
 3 files changed, 27 insertions(+), 55 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 05c5162f..089f494 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -525,34 +525,6 @@ static inline void txqs_start(struct net_device *netdev)
 }
 
 /**
- * \brief Wake Tx queues
- * @param netdev network device
- */
-static inline void txqs_wake(struct net_device *netdev)
-{
-   struct lio *lio = GET_LIO(netdev);
-
-   if (netif_is_multiqueue(netdev)) {
-   int i;
-
-   for (i = 0; i < netdev->num_tx_queues; i++) {
-   int qno = lio->linfo.txpciq[i %
-   lio->oct_dev->num_iqs].s.q_no;
-
-   if (__netif_subqueue_stopped(netdev, i)) {
-   INCR_INSTRQUEUE_PKT_COUNT(lio->oct_dev, qno,
- tx_restart, 1);
-   netif_wake_subqueue(netdev, i);
-   }
-   }
-   } else {
-   INCR_INSTRQUEUE_PKT_COUNT(lio->oct_dev, lio->txq,
- tx_restart, 1);
-   netif_wake_queue(netdev);
-   }
-}
-
-/**
  * \brief Stop Tx queue
  * @param netdev network device
  */
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
index 2e31446..60743c3 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
@@ -301,33 +301,6 @@ static void txqs_start(struct net_device *netdev)
 }
 
 /**
- * \brief Wake Tx queues
- * @param netdev network device
- */
-static void txqs_wake(struct net_device *netdev)
-{
-   struct lio *lio = GET_LIO(netdev);
-
-   if (netif_is_multiqueue(netdev)) {
-   int i;
-
-   for (i = 0; i < netdev->num_tx_queues; i++) {
-   int qno = lio->linfo.txpciq[i % lio->oct_dev->num_iqs]
- .s.q_no;
-   if (__netif_subqueue_stopped(netdev, i)) {
-   INCR_INSTRQUEUE_PKT_COUNT(lio->oct_dev, qno,
- tx_restart, 1);
-   netif_wake_subqueue(netdev, i);
-   }
-   }
-   } else {
-   INCR_INSTRQUEUE_PKT_COUNT(lio->oct_dev, lio->txq,
- tx_restart, 1);
-   netif_wake_queue(netdev);
-   }
-}
-
-/**
  * \brief Start Tx queue
  * @param netdev network device
  */
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_network.h 
b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
index d8079e35..2d2f49b 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_network.h
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
@@ -522,4 +522,31 @@ static inline void txqs_stop(struct net_device *netdev)
}
 }
 
+/**
+ * \brief Wake Tx queues
+ * @param netdev network device
+ */
+static inline void txqs_wake(struct net_device *netdev)
+{
+   struct lio *lio = GET_LIO(netdev);
+
+   if (netif_is_multiqueue(netdev)) {
+   int i;
+
+   for (i = 0; i < netdev->num_tx_queues; i++) {
+   int qno = lio->linfo.txpciq[i %
+   lio->oct_dev->num_iqs].s.q_no;
+
+   if (__netif_subqueue_stopped(netdev, i)) {
+   INCR_INSTRQUEUE_PKT_COUNT(lio->oct_dev, qno,
+ tx_restart, 1);
+   netif_wake_subqueue(netdev, i);
+   }
+   }
+   } else {
+   INCR_INSTRQUEUE_PKT_COUNT(lio->oct_dev, lio->txq,
+ tx_restart, 1);
+   netif_wake_queue(netdev);
+   }
+}
 #endif
-- 
1.8.3.1



[PATCH net-next 01/13] liquidio: Moved common function txqs_stop to octeon_network.h

2018-03-23 Thread Felix Manlunas
From: Intiyaz Basha 

Moving common function txqs_stop to octeon_network.h

Signed-off-by: Intiyaz Basha 
Acked-by: Derek Chickles 
Signed-off-by: Felix Manlunas 
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c   | 16 
 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c| 16 
 drivers/net/ethernet/cavium/liquidio/octeon_network.h | 16 
 3 files changed, 16 insertions(+), 32 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 140085b..05c5162f 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -509,22 +509,6 @@ static void liquidio_deinit_pci(void)
 }
 
 /**
- * \brief Stop Tx queues
- * @param netdev network device
- */
-static inline void txqs_stop(struct net_device *netdev)
-{
-   if (netif_is_multiqueue(netdev)) {
-   int i;
-
-   for (i = 0; i < netdev->num_tx_queues; i++)
-   netif_stop_subqueue(netdev, i);
-   } else {
-   netif_stop_queue(netdev);
-   }
-}
-
-/**
  * \brief Start Tx queues
  * @param netdev network device
  */
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
index 3342d64..2e31446 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
@@ -285,22 +285,6 @@ static pci_ers_result_t 
liquidio_pcie_error_detected(struct pci_dev *pdev,
 };
 
 /**
- * \brief Stop Tx queues
- * @param netdev network device
- */
-static void txqs_stop(struct net_device *netdev)
-{
-   if (netif_is_multiqueue(netdev)) {
-   int i;
-
-   for (i = 0; i < netdev->num_tx_queues; i++)
-   netif_stop_subqueue(netdev, i);
-   } else {
-   netif_stop_queue(netdev);
-   }
-}
-
-/**
  * \brief Start Tx queues
  * @param netdev network device
  */
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_network.h 
b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
index 76803a5..d8079e35 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_network.h
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
@@ -506,4 +506,20 @@ static inline int wait_for_pending_requests(struct 
octeon_device *oct)
return 0;
 }
 
+/**
+ * \brief Stop Tx queues
+ * @param netdev network device
+ */
+static inline void txqs_stop(struct net_device *netdev)
+{
+   if (netif_is_multiqueue(netdev)) {
+   int i;
+
+   for (i = 0; i < netdev->num_tx_queues; i++)
+   netif_stop_subqueue(netdev, i);
+   } else {
+   netif_stop_queue(netdev);
+   }
+}
+
 #endif
-- 
1.8.3.1



[PATCH net-next 00/13] liquidio: Tx queue cleanup

2018-03-23 Thread Felix Manlunas
From: Intiyaz Basha 

Moved some common function to octeon_network.h
Removed some unwanted functions and checks.

Intiyaz Basha (13):
  liquidio: Moved common function txqs_stop to octeon_network.h
  liquidio: Moved common function txqs_wake to octeon_network.h
  liquidio: Moved common function txqs_start to octeon_network.h
  liquidio: Moved common function skb_iq to to octeon_network.h
  liquidio: Removed one line function stop_txq
  liquidio: Removed start_txq function
  liquidio: Removed netif_is_multiqueue check
  liquidio: Removed one line function stop_q
  liquidio: Removed one line function wake_q
  liquidio: Function call skb_iq for deriving queue from skb
  liquidio: Renamed txqs_wake to wake_txqs
  liquidio: Renamed txqs_stop to stop_txqs
  liquidio: Renamed txqs_start to start_txqs

 drivers/net/ethernet/cavium/liquidio/lio_core.c|  18 +-
 drivers/net/ethernet/cavium/liquidio/lio_main.c| 213 -
 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c | 167 ++--
 .../net/ethernet/cavium/liquidio/octeon_network.h  |  52 +
 4 files changed, 109 insertions(+), 341 deletions(-)

-- 
1.8.3.1



Re: [PATCH v7 0/7] netdev: intel: Eliminate duplicate barriers on weakly-ordered archs

2018-03-23 Thread Jeff Kirsher
On Fri, 2018-03-23 at 14:53 -0700, Alexander Duyck wrote:
> On Fri, Mar 23, 2018 at 11:52 AM, Sinan Kaya 
> wrote:
> > Code includes wmb() followed by writel() in multiple places. writel()
> > already has a barrier on some architectures like arm64.
> > 
> > This ends up CPU observing two barriers back to back before executing
> > the
> > register write.
> > 
> > Since code already has an explicit barrier call, changing writel() to
> > writel_relaxed().
> > 
> > I did a regex search for wmb() followed by writel() in each drivers
> > directory.
> > I scrubbed the ones I care about in this series.
> > 
> > I considered "ease of change", "popular usage" and "performance
> > critical
> > path" as the determining criteria for my filtering.
> > 
> > We used relaxed API heavily on ARM for a long time but
> > it did not exist on other architectures. For this reason, relaxed
> > architectures have been paying double penalty in order to use the
> > common
> > drivers.
> > 
> > Now that relaxed API is present on all architectures, we can go and
> > scrub
> > all drivers to see what needs to change and what can remain.
> > 
> > We start with mostly used ones and hope to increase the coverage over
> > time.
> > It will take a while to cover all drivers.
> > 
> > Feel free to apply patches individually.
> 
> I looked over the set and they seem good.
> 
> Reviewed-by: Alexander Duyck 

Grrr, patch 1 does not apply cleanly to my next-queue tree (dev-queue
branch).  I will deal with this series in a day or two, after I have dealt
with my driver pull requests.

> > 
> > Changes since v6:
> > clean up between 2..6 and then make your Alex's changes on 1 and 7
> > The mmiowb shouldn't be needed for Rx. Only one CPU will be running
> > NAPI for the queue and we will synchronize this with a full writel
> > anyway when we re-enable the interrupts.
> > 
> > Sinan Kaya (7):
> >   i40e/i40evf: Eliminate duplicate barriers on weakly-ordered archs
> >   ixgbe: eliminate duplicate barriers on weakly-ordered archs
> >   igbvf: eliminate duplicate barriers on weakly-ordered archs
> >   igb: eliminate duplicate barriers on weakly-ordered archs
> >   fm10k: Eliminate duplicate barriers on weakly-ordered archs
> >   ixgbevf: keep writel() closer to wmb()
> >   ixgbevf: eliminate duplicate barriers on weakly-ordered archs
> > 
> >  drivers/net/ethernet/intel/fm10k/fm10k_main.c |  4 ++--
> >  drivers/net/ethernet/intel/i40e/i40e_txrx.c   | 14 ++
> >  drivers/net/ethernet/intel/i40evf/i40e_txrx.c |  4 ++--
> >  drivers/net/ethernet/intel/igb/igb_main.c |  4 ++--
> >  drivers/net/ethernet/intel/igbvf/netdev.c |  4 ++--
> >  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |  8 
> >  drivers/net/ethernet/intel/ixgbevf/ixgbevf.h  |  5 -
> >  drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 11 ---
> >  8 files changed, 30 insertions(+), 24 deletions(-)
> > 
> > --
> > 2.7.4
> > 


signature.asc
Description: This is a digitally signed message part


[PATCH] net: qualcomm: rmnet: check for null ep to avoid null pointer dereference

2018-03-23 Thread Colin King
From: Colin Ian King 

The call to rmnet_get_endpoint can potentially return NULL so check
for this to avoid any subsequent null pointer dereferences on a NULL
ep.

Detected by CoverityScan, CID#1465385 ("Dereference null return value")

Fixes: 23790ef12082 ("net: qualcomm: rmnet: Allow to configure flags for 
existing devices")
Signed-off-by: Colin Ian King 
---
 drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c 
b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
index 38d9356ebcc4..d33988570217 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
@@ -312,6 +312,8 @@ static int rmnet_changelink(struct net_device *dev, struct 
nlattr *tb[],
if (data[IFLA_RMNET_MUX_ID]) {
mux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]);
ep = rmnet_get_endpoint(port, priv->mux_id);
+   if (!ep)
+   return -ENODEV;
 
hlist_del_init_rcu(>hlnode);
hlist_add_head_rcu(>hlnode, >muxed_ep[mux_id]);
-- 
2.15.1



Re: [RFC v3 net-next 13/18] net/sched: Introduce the TBS Qdisc

2018-03-23 Thread Jesus Sanchez-Palencia
Hi Thomas,


On 03/23/2018 01:49 AM, Thomas Gleixner wrote:
> On Thu, 22 Mar 2018, Jesus Sanchez-Palencia wrote:
>> On 03/22/2018 03:11 PM, Thomas Gleixner wrote:
>> So, are you just opposing to the case where sorting off + offload off is 
>> used?
>> (i.e. the scheduled FIFO case)
> 
> FIFO does not make any sense if your packets have a fixed transmission
> time. I yet have to see a reasonable explanation why FIFO in the context of
> time ordered would be a good thing.


On context of tbs, the scheduled FIFO was developed just so consistency was kept
between all 4 variants, basically (sw best-effort or hw offload vs sorting
enabled or sorting disabled).

I don't have any strong argument in favor of this mode at the moment, so I will
just remove it on a next version - unless someone else brings up a valid use
case for it, of course.

Thanks for the feedback,
Jesus


[PATCH 1/4] ethernet: Use octal not symbolic permissions

2018-03-23 Thread Joe Perches
Prefer the direct use of octal for permissions.

Done with checkpatch -f --types=SYMBOLIC_PERMS --fix-inplace
and some typing.

Miscellanea:

o Whitespace neatening around these conversions.

Signed-off-by: Joe Perches 
---
 drivers/net/ethernet/8390/apne.c   |   2 +-
 drivers/net/ethernet/8390/lib8390.c|   2 +-
 drivers/net/ethernet/8390/ne.c |   2 +-
 drivers/net/ethernet/8390/ne2k-pci.c   |   2 +-
 drivers/net/ethernet/8390/smc-ultra.c  |   2 +-
 drivers/net/ethernet/8390/stnic.c  |   2 +-
 drivers/net/ethernet/8390/wd.c |   2 +-
 drivers/net/ethernet/altera/altera_tse_main.c  |   6 +-
 drivers/net/ethernet/amd/xgbe/xgbe-drv.c   |  10 +-
 drivers/net/ethernet/amd/xgbe/xgbe-main.c  |   2 +-
 drivers/net/ethernet/broadcom/bnx2.c   |   2 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c   |  12 +--
 drivers/net/ethernet/broadcom/sb1250-mac.c |  10 +-
 drivers/net/ethernet/broadcom/tg3.c|   6 +-
 drivers/net/ethernet/brocade/bna/bnad.c|   2 +-
 drivers/net/ethernet/brocade/bna/bnad_debugfs.c|  10 +-
 drivers/net/ethernet/cavium/thunder/nicvf_main.c   |   2 +-
 drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c|   6 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 112 ++---
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c|  10 +-
 drivers/net/ethernet/ec_bhf.c  |   2 +-
 drivers/net/ethernet/emulex/benet/be_main.c|   6 +-
 drivers/net/ethernet/ibm/ehea/ehea_main.c  |   7 +-
 drivers/net/ethernet/ibm/ibmveth.c |   2 +-
 drivers/net/ethernet/intel/igb/igb_hwmon.c |   2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c |   2 +-
 drivers/net/ethernet/marvell/mvneta.c  |   8 +-
 drivers/net/ethernet/marvell/skge.c|   2 +-
 drivers/net/ethernet/marvell/sky2.c|   2 +-
 drivers/net/ethernet/mellanox/mlx4/main.c  |  16 +--
 drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c   |  10 +-
 drivers/net/ethernet/myricom/myri10ge/myri10ge.c   |  32 +++---
 .../net/ethernet/netronome/nfp/nfp_net_debugfs.c   |   6 +-
 .../net/ethernet/qlogic/netxen/netxen_nic_main.c   |  14 +--
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c  |  30 +++---
 drivers/net/ethernet/qualcomm/qca_debug.c  |   2 +-
 drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c|   4 +-
 drivers/net/ethernet/sfc/mcdi_mon.c|   2 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  |  26 ++---
 drivers/net/ethernet/sun/niu.c |  10 +-
 40 files changed, 194 insertions(+), 195 deletions(-)

diff --git a/drivers/net/ethernet/8390/apne.c b/drivers/net/ethernet/8390/apne.c
index c56ac9ebc08f..fe6c834c422e 100644
--- a/drivers/net/ethernet/8390/apne.c
+++ b/drivers/net/ethernet/8390/apne.c
@@ -117,7 +117,7 @@ static const char version[] =
 static int apne_owned; /* signal if card already owned */
 
 static u32 apne_msg_enable;
-module_param_named(msg_enable, apne_msg_enable, uint, 
(S_IRUSR|S_IRGRP|S_IROTH));
+module_param_named(msg_enable, apne_msg_enable, uint, 0444);
 MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for 
bitmap)");
 
 struct net_device * __init apne_probe(int unit)
diff --git a/drivers/net/ethernet/8390/lib8390.c 
b/drivers/net/ethernet/8390/lib8390.c
index 5d9bbde9fe68..c9c55c9eab9f 100644
--- a/drivers/net/ethernet/8390/lib8390.c
+++ b/drivers/net/ethernet/8390/lib8390.c
@@ -113,7 +113,7 @@ static void __NS8390_init(struct net_device *dev, int 
startp);
 
 static unsigned version_printed;
 static u32 msg_enable;
-module_param(msg_enable, uint, (S_IRUSR|S_IRGRP|S_IROTH));
+module_param(msg_enable, uint, 0444);
 MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for 
bitmap)");
 
 /*
diff --git a/drivers/net/ethernet/8390/ne.c b/drivers/net/ethernet/8390/ne.c
index 44a084b41bf0..ac99d089ac72 100644
--- a/drivers/net/ethernet/8390/ne.c
+++ b/drivers/net/ethernet/8390/ne.c
@@ -77,7 +77,7 @@ static u32 ne_msg_enable;
 module_param_hw_array(io, int, ioport, NULL, 0);
 module_param_hw_array(irq, int, irq, NULL, 0);
 module_param_array(bad, int, NULL, 0);
-module_param_named(msg_enable, ne_msg_enable, uint, (S_IRUSR|S_IRGRP|S_IROTH));
+module_param_named(msg_enable, ne_msg_enable, uint, 0444);
 MODULE_PARM_DESC(io, "I/O base address(es),required");
 MODULE_PARM_DESC(irq, "IRQ number(s)");
 MODULE_PARM_DESC(bad, "Accept card(s) with bad signatures");
diff --git a/drivers/net/ethernet/8390/ne2k-pci.c 
b/drivers/net/ethernet/8390/ne2k-pci.c
index 1bdea746926c..42985a82321a 100644
--- a/drivers/net/ethernet/8390/ne2k-pci.c
+++ b/drivers/net/ethernet/8390/ne2k-pci.c
@@ -76,7 +76,7 @@ MODULE_AUTHOR("Donald Becker / Paul Gortmaker");
 MODULE_DESCRIPTION("PCI NE2000 clone driver");
 MODULE_LICENSE("GPL");
 

[net-next 03/12] ixgbe: no need for ipsec csum feature check

2018-03-23 Thread Jeff Kirsher
From: Shannon Nelson 

With the patch
commit f8aa2696b4af ("esp: check the NETIF_F_HW_ESP_TX_CSUM bit before 
segmenting")
we no longer need to protect ourself from checksum
offload requests on IPsec packets, so we can remove
the check in our .ndo_features_check callback.

Signed-off-by: Shannon Nelson 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index faf368b14389..0eb45d1cd0b2 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -9917,12 +9917,6 @@ ixgbe_features_check(struct sk_buff *skb, struct 
net_device *dev,
if (skb->encapsulation && !(features & NETIF_F_TSO_MANGLEID))
features &= ~NETIF_F_TSO;
 
-#ifdef CONFIG_XFRM_OFFLOAD
-   /* IPsec offload doesn't get along well with others *yet* */
-   if (skb->sp)
-   features &= ~(NETIF_F_TSO | NETIF_F_HW_CSUM);
-#endif
-
return features;
 }
 
-- 
2.14.3



[net-next 02/12] ixgbe: fix read-modify-write in x550 phy setup

2018-03-23 Thread Jeff Kirsher
From: Paul Greenwalt 

Replaced an assignment operation with an OR operation.

The variable assignment was overwriting the value read from the PHY
register. The OR operation sets only the intended register bits.

The bits that were being overwritten are reserved, so the assignment had no
functional impact.

Reported by: Shannon Nelson 
Signed-off-by: Paul Greenwalt 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
index f470d0204771..3123267dfba9 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
@@ -1847,9 +1847,9 @@ ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw, 
ixgbe_link_speed speed,
 (IXGBE_CS4227_EDC_MODE_SR << 1));
 
if (setup_linear)
-   reg_phy_ext = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 1;
+   reg_phy_ext |= (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 1;
else
-   reg_phy_ext = (IXGBE_CS4227_EDC_MODE_SR << 1) | 1;
+   reg_phy_ext |= (IXGBE_CS4227_EDC_MODE_SR << 1) | 1;
 
ret_val = hw->phy.ops.write_reg(hw, reg_slice,
IXGBE_MDIO_ZERO_DEV_TYPE, reg_phy_ext);
-- 
2.14.3



[net-next 12/12] ixgbe: tweak page counting for XDP_REDIRECT

2018-03-23 Thread Jeff Kirsher
From: Björn Töpel 

The current page counting scheme assumes that the reference count
cannot decrease until the received frame is sent to the upper layers
of the networking stack. This assumption does not hold for the
XDP_REDIRECT action, since a page (pointed out by xdp_buff) can have
its reference count decreased via the xdp_do_redirect call.

To work around that, we now start off by a large page count and then
don't allow a refcount less than two.

Signed-off-by: Björn Töpel 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index c0d8d7238f71..afadba99f7b8 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -1629,7 +1629,8 @@ static bool ixgbe_alloc_mapped_page(struct ixgbe_ring 
*rx_ring,
bi->dma = dma;
bi->page = page;
bi->page_offset = ixgbe_rx_offset(rx_ring);
-   bi->pagecnt_bias = 1;
+   page_ref_add(page, USHRT_MAX - 1);
+   bi->pagecnt_bias = USHRT_MAX;
rx_ring->rx_stats.alloc_rx_page++;
 
return true;
@@ -2039,8 +2040,8 @@ static bool ixgbe_can_reuse_rx_page(struct 
ixgbe_rx_buffer *rx_buffer)
 * the pagecnt_bias and page count so that we fully restock the
 * number of references the driver holds.
 */
-   if (unlikely(!pagecnt_bias)) {
-   page_ref_add(page, USHRT_MAX);
+   if (unlikely(pagecnt_bias == 1)) {
+   page_ref_add(page, USHRT_MAX - 1);
rx_buffer->pagecnt_bias = USHRT_MAX;
}
 
-- 
2.14.3



[net-next 08/12] ixgbevf: Add support for XDP_TX action

2018-03-23 Thread Jeff Kirsher
From: Tony Nguyen 

This implements the XDP_TX action which is modeled on the ixgbe
implementation. However instead of using CPU id to determine which XDP
queue to use, this uses the received RX queue index, which is similar
to i40e. Doing this eliminates the restriction that number of CPUs not
exceed number of XDP queues that ixgbe has.

Also, based on the number of queues available, the number of TX queues
may be reduced when an XDP program is loaded in order to accommodate the
XDP queues.

Based largely on
commit 33fdc82f0883 ("ixgbe: add support for XDP_TX action")

Signed-off-by: Tony Nguyen 
Acked-by: John Fastabend 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/ixgbevf/ethtool.c  |  35 ++-
 drivers/net/ethernet/intel/ixgbevf/ixgbevf.h  |  20 +-
 drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 271 +++---
 3 files changed, 294 insertions(+), 32 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbevf/ethtool.c 
b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
index 4946a62c70a4..da8c0e299a37 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
@@ -269,7 +269,7 @@ static int ixgbevf_set_ringparam(struct net_device *netdev,
struct ixgbevf_adapter *adapter = netdev_priv(netdev);
struct ixgbevf_ring *tx_ring = NULL, *rx_ring = NULL;
u32 new_rx_count, new_tx_count;
-   int i, err = 0;
+   int i, j, err = 0;
 
if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
return -EINVAL;
@@ -293,15 +293,19 @@ static int ixgbevf_set_ringparam(struct net_device 
*netdev,
if (!netif_running(adapter->netdev)) {
for (i = 0; i < adapter->num_tx_queues; i++)
adapter->tx_ring[i]->count = new_tx_count;
+   for (i = 0; i < adapter->num_xdp_queues; i++)
+   adapter->xdp_ring[i]->count = new_tx_count;
for (i = 0; i < adapter->num_rx_queues; i++)
adapter->rx_ring[i]->count = new_rx_count;
adapter->tx_ring_count = new_tx_count;
+   adapter->xdp_ring_count = new_tx_count;
adapter->rx_ring_count = new_rx_count;
goto clear_reset;
}
 
if (new_tx_count != adapter->tx_ring_count) {
-   tx_ring = vmalloc(adapter->num_tx_queues * sizeof(*tx_ring));
+   tx_ring = vmalloc((adapter->num_tx_queues +
+  adapter->num_xdp_queues) * sizeof(*tx_ring));
if (!tx_ring) {
err = -ENOMEM;
goto clear_reset;
@@ -324,6 +328,24 @@ static int ixgbevf_set_ringparam(struct net_device *netdev,
goto clear_reset;
}
}
+
+   for (j = 0; j < adapter->num_xdp_queues; i++, j++) {
+   /* clone ring and setup updated count */
+   tx_ring[i] = *adapter->xdp_ring[j];
+   tx_ring[i].count = new_tx_count;
+   err = ixgbevf_setup_tx_resources(_ring[i]);
+   if (err) {
+   while (i) {
+   i--;
+   ixgbevf_free_tx_resources(_ring[i]);
+   }
+
+   vfree(tx_ring);
+   tx_ring = NULL;
+
+   goto clear_reset;
+   }
+   }
}
 
if (new_rx_count != adapter->rx_ring_count) {
@@ -368,6 +390,12 @@ static int ixgbevf_set_ringparam(struct net_device *netdev,
}
adapter->tx_ring_count = new_tx_count;
 
+   for (j = 0; j < adapter->num_xdp_queues; i++, j++) {
+   ixgbevf_free_tx_resources(adapter->xdp_ring[j]);
+   *adapter->xdp_ring[j] = tx_ring[i];
+   }
+   adapter->xdp_ring_count = new_tx_count;
+
vfree(tx_ring);
tx_ring = NULL;
}
@@ -390,7 +418,8 @@ static int ixgbevf_set_ringparam(struct net_device *netdev,
 clear_reset:
/* free Tx resources if Rx error is encountered */
if (tx_ring) {
-   for (i = 0; i < adapter->num_tx_queues; i++)
+   for (i = 0;
+i < adapter->num_tx_queues + adapter->num_xdp_queues; i++)
ixgbevf_free_tx_resources(_ring[i]);
vfree(tx_ring);
}
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h 
b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
index d41365b1b674..447ce1d5e0e3 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
+++ 

[net-next 00/12][pull request] 10GbE Intel Wired LAN Driver Updates 2018-03-23

2018-03-23 Thread Jeff Kirsher
This series contains updates to ixgbe and ixgbevf only.

Paul adds status register reads to reduce a potential race condition
where registers can read 0x during a PCI reset, which in turn
causes the driver to remove the adapter.  Then fixes an assignment
operation with an "OR" operation.

Shannon Nelson provides several IPsec offload cleanups to ixgbe, as well as a
patch to enable TSO with IPsec offload.

Tony provides the much anticipated XDP support for ixgbevf.  Currently,
pass, drop and XDP_TX actions are supported, as well as meta data and
stats reporting.

Björn Töpel tweaks the page counting for XDP_REDIRECT, since a page can
have its reference count decreased via the xdp_do_redirect() call.

The following are changes since commit f452518c982e57538e6d49da0a2c80eef22087ab:
  net: phy: intel-xway: add VR9 v1.1 phy ids
and are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue 10GbE

Björn Töpel (1):
  ixgbe: tweak page counting for XDP_REDIRECT

Paul Greenwalt (2):
  ixgbe: add status reg reads to ixgbe_check_remove
  ixgbe: fix read-modify-write in x550 phy setup

Shannon Nelson (4):
  ixgbe: no need for ipsec csum feature check
  ixgbe: remove unneeded ipsec test in TX path
  ixgbe: no need for esp trailer if GSO
  ixgbe: enable TSO with IPsec offload

Tony Nguyen (5):
  ixgbevf: Add XDP support for pass and drop actions
  ixgbevf: Add support for XDP_TX action
  ixgbevf: Delay tail write for XDP packets
  ixgbevf: Add support for meta data
  ixgbevf: Add XDP queue stats reporting

 drivers/net/ethernet/intel/ixgbe/ixgbe_common.h   |   1 +
 drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c|  46 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |  79 ++--
 drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c |   4 +-
 drivers/net/ethernet/intel/ixgbevf/ethtool.c  |  68 ++-
 drivers/net/ethernet/intel/ixgbevf/ixgbevf.h  |  30 +-
 drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 489 +++---
 7 files changed, 596 insertions(+), 121 deletions(-)

-- 
2.14.3



[net-next 09/12] ixgbevf: Delay tail write for XDP packets

2018-03-23 Thread Jeff Kirsher
From: Tony Nguyen 

Current XDP implementation hits the tail on every XDP_TX; change the
driver to only hit the tail after packet processing is complete.

Based on
commit 7379f97a4fce ("ixgbe: delay tail write to every 'n' packets")

Signed-off-by: Tony Nguyen 
Acked-by: John Fastabend 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 30 ++-
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c 
b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index 309f549808e4..5167e81e0cf1 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -1016,14 +1016,8 @@ static int ixgbevf_xmit_xdp_ring(struct ixgbevf_ring 
*ring,
cpu_to_le32((len << IXGBE_ADVTXD_PAYLEN_SHIFT) |
IXGBE_ADVTXD_CC);
 
-   /* Force memory writes to complete before letting h/w know there
-* are new descriptors to fetch.  (Only applicable for weak-ordered
-* memory model archs, such as IA-64).
-*
-* We also need this memory barrier to make certain all of the
-* status bits have been updated before next_to_watch is written.
-*/
-   wmb();
+   /* Avoid any potential race with cleanup */
+   smp_wmb();
 
/* set next_to_watch value indicating a packet is present */
i++;
@@ -1033,8 +1027,6 @@ static int ixgbevf_xmit_xdp_ring(struct ixgbevf_ring 
*ring,
tx_buffer->next_to_watch = tx_desc;
ring->next_to_use = i;
 
-   /* notify HW of packet */
-   ixgbevf_write_tail(ring, i);
return IXGBEVF_XDP_TX;
 }
 
@@ -1101,6 +1093,7 @@ static int ixgbevf_clean_rx_irq(struct ixgbevf_q_vector 
*q_vector,
struct ixgbevf_adapter *adapter = q_vector->adapter;
u16 cleaned_count = ixgbevf_desc_unused(rx_ring);
struct sk_buff *skb = rx_ring->skb;
+   bool xdp_xmit = false;
struct xdp_buff xdp;
 
xdp.rxq = _ring->xdp_rxq;
@@ -1142,11 +1135,13 @@ static int ixgbevf_clean_rx_irq(struct ixgbevf_q_vector 
*q_vector,
}
 
if (IS_ERR(skb)) {
-   if (PTR_ERR(skb) == -IXGBEVF_XDP_TX)
+   if (PTR_ERR(skb) == -IXGBEVF_XDP_TX) {
+   xdp_xmit = true;
ixgbevf_rx_buffer_flip(rx_ring, rx_buffer,
   size);
-   else
+   } else {
rx_buffer->pagecnt_bias++;
+   }
total_rx_packets++;
total_rx_bytes += size;
} else if (skb) {
@@ -1208,6 +1203,17 @@ static int ixgbevf_clean_rx_irq(struct ixgbevf_q_vector 
*q_vector,
/* place incomplete frames back on ring for completion */
rx_ring->skb = skb;
 
+   if (xdp_xmit) {
+   struct ixgbevf_ring *xdp_ring =
+   adapter->xdp_ring[rx_ring->queue_index];
+
+   /* Force memory writes to complete before letting h/w
+* know there are new descriptors to fetch.
+*/
+   wmb();
+   ixgbevf_write_tail(xdp_ring, xdp_ring->next_to_use);
+   }
+
u64_stats_update_begin(_ring->syncp);
rx_ring->stats.packets += total_rx_packets;
rx_ring->stats.bytes += total_rx_bytes;
-- 
2.14.3



[net-next 05/12] ixgbe: no need for esp trailer if GSO

2018-03-23 Thread Jeff Kirsher
From: Shannon Nelson 

There is no need to calculate the trailer length if we're doing
a GSO/TSO, as there is no trailer added to the packet data.
Also, don't bother clearing the flags field as it was already
cleared earlier.

Signed-off-by: Shannon Nelson 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c | 37 +++---
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
index f2254528dcfc..5ddea43a21c2 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
@@ -774,11 +774,7 @@ int ixgbe_ipsec_tx(struct ixgbe_ring *tx_ring,
 
first->tx_flags |= IXGBE_TX_FLAGS_IPSEC | IXGBE_TX_FLAGS_CC;
 
-   itd->flags = 0;
if (xs->id.proto == IPPROTO_ESP) {
-   struct sk_buff *skb = first->skb;
-   int ret, authlen, trailerlen;
-   u8 padlen;
 
itd->flags |= IXGBE_ADVTXD_TUCMD_IPSEC_TYPE_ESP |
  IXGBE_ADVTXD_TUCMD_L4T_TCP;
@@ -790,19 +786,28 @@ int ixgbe_ipsec_tx(struct ixgbe_ring *tx_ring,
 * padlen bytes of padding.  This ends up not the same
 * as the static value found in xs->props.trailer_len (21).
 *
-* The "correct" way to get the auth length would be to use
-*authlen = crypto_aead_authsize(xs->data);
-* but since we know we only have one size to worry about
-* we can let the compiler use the constant and save us a
-* few CPU cycles.
+* ... but if we're doing GSO, don't bother as the stack
+* doesn't add a trailer for those.
 */
-   authlen = IXGBE_IPSEC_AUTH_BITS / 8;
-
-   ret = skb_copy_bits(skb, skb->len - (authlen + 2), , 1);
-   if (unlikely(ret))
-   return 0;
-   trailerlen = authlen + 2 + padlen;
-   itd->trailer_len = trailerlen;
+   if (!skb_is_gso(first->skb)) {
+   /* The "correct" way to get the auth length would be
+* to use
+*authlen = crypto_aead_authsize(xs->data);
+* but since we know we only have one size to worry
+* about * we can let the compiler use the constant
+* and save us a few CPU cycles.
+*/
+   const int authlen = IXGBE_IPSEC_AUTH_BITS / 8;
+   struct sk_buff *skb = first->skb;
+   u8 padlen;
+   int ret;
+
+   ret = skb_copy_bits(skb, skb->len - (authlen + 2),
+   , 1);
+   if (unlikely(ret))
+   return 0;
+   itd->trailer_len = authlen + 2 + padlen;
+   }
}
if (tsa->encrypt)
itd->flags |= IXGBE_ADVTXD_TUCMD_IPSEC_ENCRYPT_EN;
-- 
2.14.3



[net-next 04/12] ixgbe: remove unneeded ipsec test in TX path

2018-03-23 Thread Jeff Kirsher
From: Shannon Nelson 

Since the ipsec data fields will be zero anyway in the non-ipsec
case, we can remove the conditional jump.

Suggested-by: Alexander Duyck 
Signed-off-by: Shannon Nelson 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 0eb45d1cd0b2..74da310378da 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -7873,10 +7873,8 @@ static void ixgbe_tx_csum(struct ixgbe_ring *tx_ring,
vlan_macip_lens |= skb_network_offset(skb) << IXGBE_ADVTXD_MACLEN_SHIFT;
vlan_macip_lens |= first->tx_flags & IXGBE_TX_FLAGS_VLAN_MASK;
 
-   if (first->tx_flags & IXGBE_TX_FLAGS_IPSEC) {
-   fceof_saidx |= itd->sa_idx;
-   type_tucmd |= itd->flags | itd->trailer_len;
-   }
+   fceof_saidx |= itd->sa_idx;
+   type_tucmd |= itd->flags | itd->trailer_len;
 
ixgbe_tx_ctxtdesc(tx_ring, vlan_macip_lens, fceof_saidx, type_tucmd, 0);
 }
-- 
2.14.3



[net-next 11/12] ixgbevf: Add XDP queue stats reporting

2018-03-23 Thread Jeff Kirsher
From: Tony Nguyen 

XDP stats are included in TX stats, however, they are not
reported in TX queue stats since they are setup on different
queues.  Add reporting for XDP queue stats to provide
consistency between the total stats and per queue stats.

Signed-off-by: Tony Nguyen 
Acked-by: John Fastabend 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/ixgbevf/ethtool.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/drivers/net/ethernet/intel/ixgbevf/ethtool.c 
b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
index da8c0e299a37..8e7d6c6f5c92 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
@@ -82,6 +82,7 @@ static struct ixgbe_stats ixgbevf_gstrings_stats[] = {
 
 #define IXGBEVF_QUEUE_STATS_LEN ( \
(((struct ixgbevf_adapter *)netdev_priv(netdev))->num_tx_queues + \
+((struct ixgbevf_adapter *)netdev_priv(netdev))->num_xdp_queues + \
 ((struct ixgbevf_adapter *)netdev_priv(netdev))->num_rx_queues) * \
 (sizeof(struct ixgbevf_stats) / sizeof(u64)))
 #define IXGBEVF_GLOBAL_STATS_LEN ARRAY_SIZE(ixgbevf_gstrings_stats)
@@ -491,6 +492,23 @@ static void ixgbevf_get_ethtool_stats(struct net_device 
*netdev,
i += 2;
}
 
+   /* populate XDP queue data */
+   for (j = 0; j < adapter->num_xdp_queues; j++) {
+   ring = adapter->xdp_ring[j];
+   if (!ring) {
+   data[i++] = 0;
+   data[i++] = 0;
+   continue;
+   }
+
+   do {
+   start = u64_stats_fetch_begin_irq(>syncp);
+   data[i] = ring->stats.packets;
+   data[i + 1] = ring->stats.bytes;
+   } while (u64_stats_fetch_retry_irq(>syncp, start));
+   i += 2;
+   }
+
/* populate Rx queue data */
for (j = 0; j < adapter->num_rx_queues; j++) {
ring = adapter->rx_ring[j];
@@ -534,6 +552,12 @@ static void ixgbevf_get_strings(struct net_device *netdev, 
u32 stringset,
sprintf(p, "tx_queue_%u_bytes", i);
p += ETH_GSTRING_LEN;
}
+   for (i = 0; i < adapter->num_xdp_queues; i++) {
+   sprintf(p, "xdp_queue_%u_packets", i);
+   p += ETH_GSTRING_LEN;
+   sprintf(p, "xdp_queue_%u_bytes", i);
+   p += ETH_GSTRING_LEN;
+   }
for (i = 0; i < adapter->num_rx_queues; i++) {
sprintf(p, "rx_queue_%u_packets", i);
p += ETH_GSTRING_LEN;
-- 
2.14.3



[net-next 07/12] ixgbevf: Add XDP support for pass and drop actions

2018-03-23 Thread Jeff Kirsher
From: Tony Nguyen 

Implement XDP_PASS and XDP_DROP based on the ixgbe implementation.

Based largely on commit 924708081629 ("ixgbe: add XDP support for pass and
drop actions").

Signed-off-by: Tony Nguyen 
Acked-by: John Fastabend 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/ixgbevf/ethtool.c  |   9 +-
 drivers/net/ethernet/intel/ixgbevf/ixgbevf.h  |  10 +-
 drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 201 ++
 3 files changed, 178 insertions(+), 42 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbevf/ethtool.c 
b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
index e7623fed42da..4946a62c70a4 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
@@ -1,7 +1,7 @@
 
/***
 
   Intel 82599 Virtual Function driver
-  Copyright(c) 1999 - 2015 Intel Corporation.
+  Copyright(c) 1999 - 2018 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
@@ -336,8 +336,13 @@ static int ixgbevf_set_ringparam(struct net_device *netdev,
for (i = 0; i < adapter->num_rx_queues; i++) {
/* clone ring and setup updated count */
rx_ring[i] = *adapter->rx_ring[i];
+
+   /* Clear copied XDP RX-queue info */
+   memset(_ring[i].xdp_rxq, 0,
+  sizeof(rx_ring[i].xdp_rxq));
+
rx_ring[i].count = new_rx_count;
-   err = ixgbevf_setup_rx_resources(_ring[i]);
+   err = ixgbevf_setup_rx_resources(adapter, _ring[i]);
if (err) {
while (i) {
i--;
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h 
b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
index c06ea4dc49a0..d41365b1b674 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
@@ -2,7 +2,7 @@
 
/***
 
   Intel 82599 Virtual Function driver
-  Copyright(c) 1999 - 2015 Intel Corporation.
+  Copyright(c) 1999 - 2018 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "vf.h"
 
@@ -100,6 +101,7 @@ struct ixgbevf_ring {
struct ixgbevf_ring *next;
struct ixgbevf_q_vector *q_vector;  /* backpointer to q_vector */
struct net_device *netdev;
+   struct bpf_prog *xdp_prog;
struct device *dev;
void *desc; /* descriptor ring memory */
dma_addr_t dma; /* phys. address of descriptor ring */
@@ -120,7 +122,7 @@ struct ixgbevf_ring {
struct ixgbevf_tx_queue_stats tx_stats;
struct ixgbevf_rx_queue_stats rx_stats;
};
-
+   struct xdp_rxq_info xdp_rxq;
u64 hw_csum_rx_error;
u8 __iomem *tail;
struct sk_buff *skb;
@@ -357,6 +359,7 @@ struct ixgbevf_adapter {
 
/* OS defined structs */
struct net_device *netdev;
+   struct bpf_prog *xdp_prog;
struct pci_dev *pdev;
 
/* structs defined in ixgbe_vf.h */
@@ -443,7 +446,8 @@ void ixgbevf_down(struct ixgbevf_adapter *adapter);
 void ixgbevf_reinit_locked(struct ixgbevf_adapter *adapter);
 void ixgbevf_reset(struct ixgbevf_adapter *adapter);
 void ixgbevf_set_ethtool_ops(struct net_device *netdev);
-int ixgbevf_setup_rx_resources(struct ixgbevf_ring *);
+int ixgbevf_setup_rx_resources(struct ixgbevf_adapter *adapter,
+  struct ixgbevf_ring *rx_ring);
 int ixgbevf_setup_tx_resources(struct ixgbevf_ring *);
 void ixgbevf_free_rx_resources(struct ixgbevf_ring *);
 void ixgbevf_free_tx_resources(struct ixgbevf_ring *);
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c 
b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index 4da449e0a4ba..2696b5a6806f 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -1,7 +1,7 @@
 
/***
 
   Intel 82599 Virtual Function driver
-  Copyright(c) 1999 - 2015 Intel Corporation.
+  Copyright(c) 1999 - 2018 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
@@ -50,6 +50,9 @@
 #include 
 #include 
 

[net-next 06/12] ixgbe: enable TSO with IPsec offload

2018-03-23 Thread Jeff Kirsher
From: Shannon Nelson 

Fix things up to support TSO offload in conjunction
with IPsec hw offload.  This raises throughput with
IPsec offload on to nearly line rate.

Signed-off-by: Shannon Nelson 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c |  9 ++--
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c  | 31 ++
 2 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
index 5ddea43a21c2..68af127987bc 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
@@ -929,8 +929,13 @@ void ixgbe_init_ipsec_offload(struct ixgbe_adapter 
*adapter)
ixgbe_ipsec_clear_hw_tables(adapter);
 
adapter->netdev->xfrmdev_ops = _xfrmdev_ops;
-   adapter->netdev->features |= NETIF_F_HW_ESP;
-   adapter->netdev->hw_enc_features |= NETIF_F_HW_ESP;
+
+#define IXGBE_ESP_FEATURES (NETIF_F_HW_ESP | \
+NETIF_F_HW_ESP_TX_CSUM | \
+NETIF_F_GSO_ESP)
+
+   adapter->netdev->features |= IXGBE_ESP_FEATURES;
+   adapter->netdev->hw_enc_features |= IXGBE_ESP_FEATURES;
 
return;
 
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 74da310378da..c0d8d7238f71 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -7730,7 +7730,8 @@ static void ixgbe_service_task(struct work_struct *work)
 
 static int ixgbe_tso(struct ixgbe_ring *tx_ring,
 struct ixgbe_tx_buffer *first,
-u8 *hdr_len)
+u8 *hdr_len,
+struct ixgbe_ipsec_tx_data *itd)
 {
u32 vlan_macip_lens, type_tucmd, mss_l4len_idx;
struct sk_buff *skb = first->skb;
@@ -7744,6 +7745,7 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring,
unsigned char *hdr;
} l4;
u32 paylen, l4_offset;
+   u32 fceof_saidx = 0;
int err;
 
if (skb->ip_summed != CHECKSUM_PARTIAL)
@@ -7769,13 +7771,15 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring,
if (ip.v4->version == 4) {
unsigned char *csum_start = skb_checksum_start(skb);
unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4);
+   int len = csum_start - trans_start;
 
/* IP header will have to cancel out any data that
-* is not a part of the outer IP header
+* is not a part of the outer IP header, so set to
+* a reverse csum if needed, else init check to 0.
 */
-   ip.v4->check = csum_fold(csum_partial(trans_start,
- csum_start - trans_start,
- 0));
+   ip.v4->check = (skb_shinfo(skb)->gso_type & SKB_GSO_PARTIAL) ?
+  csum_fold(csum_partial(trans_start,
+ len, 0)) : 0;
type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4;
 
ip.v4->tot_len = 0;
@@ -7806,12 +7810,15 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring,
mss_l4len_idx = (*hdr_len - l4_offset) << IXGBE_ADVTXD_L4LEN_SHIFT;
mss_l4len_idx |= skb_shinfo(skb)->gso_size << IXGBE_ADVTXD_MSS_SHIFT;
 
+   fceof_saidx |= itd->sa_idx;
+   type_tucmd |= itd->flags | itd->trailer_len;
+
/* vlan_macip_lens: HEADLEN, MACLEN, VLAN tag */
vlan_macip_lens = l4.hdr - ip.hdr;
vlan_macip_lens |= (ip.hdr - skb->data) << IXGBE_ADVTXD_MACLEN_SHIFT;
vlan_macip_lens |= first->tx_flags & IXGBE_TX_FLAGS_VLAN_MASK;
 
-   ixgbe_tx_ctxtdesc(tx_ring, vlan_macip_lens, 0, type_tucmd,
+   ixgbe_tx_ctxtdesc(tx_ring, vlan_macip_lens, fceof_saidx, type_tucmd,
  mss_l4len_idx);
 
return 1;
@@ -8502,7 +8509,7 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
if (skb->sp && !ixgbe_ipsec_tx(tx_ring, first, _tx))
goto out_drop;
 #endif
-   tso = ixgbe_tso(tx_ring, first, _len);
+   tso = ixgbe_tso(tx_ring, first, _len, _tx);
if (tso < 0)
goto out_drop;
else if (!tso)
@@ -9911,9 +9918,15 @@ ixgbe_features_check(struct sk_buff *skb, struct 
net_device *dev,
 
/* We can only support IPV4 TSO in tunnels if we can mangle the
 * inner IP ID field, so strip TSO if MANGLEID is not supported.
+* IPsec offoad sets skb->encapsulation but still can handle
+* the TSO, so it's the exception.
 */
-   if (skb->encapsulation && !(features & 

[net-next 01/12] ixgbe: add status reg reads to ixgbe_check_remove

2018-03-23 Thread Jeff Kirsher
From: Paul Greenwalt 

Add status register reads and delay between reads to ixgbe_check_remove.
Registers can read 0x during PCI reset, which causes the driver
to remove the adapter. The additional status register reads can reduce the
chance of this race condition.

If the status register is not 0x, then ixgbe_check_remove returns
the value of the register being read.

Signed-off-by: Paul Greenwalt 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_common.h |  1 +
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c   | 31 -
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
index 67f304289fd9..2b311382167a 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
@@ -154,6 +154,7 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw 
*hw,
 void ixgbe_set_soft_rate_select_speed(struct ixgbe_hw *hw,
  ixgbe_link_speed speed);
 
+#define IXGBE_FAILED_READ_RETRIES 5
 #define IXGBE_FAILED_READ_REG 0xU
 #define IXGBE_FAILED_READ_CFG_DWORD 0xU
 #define IXGBE_FAILED_READ_CFG_WORD 0xU
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 85369423452d..faf368b14389 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -353,23 +353,32 @@ static void ixgbe_remove_adapter(struct ixgbe_hw *hw)
ixgbe_service_event_schedule(adapter);
 }
 
-static void ixgbe_check_remove(struct ixgbe_hw *hw, u32 reg)
+static u32 ixgbe_check_remove(struct ixgbe_hw *hw, u32 reg)
 {
+   u8 __iomem *reg_addr;
u32 value;
+   int i;
 
-   /* The following check not only optimizes a bit by not
-* performing a read on the status register when the
-* register just read was a status register read that
-* returned IXGBE_FAILED_READ_REG. It also blocks any
-* potential recursion.
+   reg_addr = READ_ONCE(hw->hw_addr);
+   if (ixgbe_removed(reg_addr))
+   return IXGBE_FAILED_READ_REG;
+
+   /* Register read of 0xFFF can indicate the adapter has been removed,
+* so perform several status register reads to determine if the adapter
+* has been removed.
 */
-   if (reg == IXGBE_STATUS) {
-   ixgbe_remove_adapter(hw);
-   return;
+   for (i = 0; i < IXGBE_FAILED_READ_RETRIES; i++) {
+   value = readl(reg_addr + IXGBE_STATUS);
+   if (value != IXGBE_FAILED_READ_REG)
+   break;
+   mdelay(3);
}
-   value = ixgbe_read_reg(hw, IXGBE_STATUS);
+
if (value == IXGBE_FAILED_READ_REG)
ixgbe_remove_adapter(hw);
+   else
+   value = readl(reg_addr + reg);
+   return value;
 }
 
 /**
@@ -415,7 +424,7 @@ u32 ixgbe_read_reg(struct ixgbe_hw *hw, u32 reg)
 writes_completed:
value = readl(reg_addr + reg);
if (unlikely(value == IXGBE_FAILED_READ_REG))
-   ixgbe_check_remove(hw, reg);
+   value = ixgbe_check_remove(hw, reg);
return value;
 }
 
-- 
2.14.3



[net-next 10/12] ixgbevf: Add support for meta data

2018-03-23 Thread Jeff Kirsher
From: Tony Nguyen 

Add support for XDP meta data when using build skb.

Based on commit 366a88fe2f40 ("bpf, ixgbe: add meta data support")

Signed-off-by: Tony Nguyen 
Acked-by: John Fastabend 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 29 +++
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c 
b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index 5167e81e0cf1..3d9033f26eff 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -889,6 +889,20 @@ struct sk_buff *ixgbevf_construct_skb(struct ixgbevf_ring 
*rx_ring,
 #if L1_CACHE_BYTES < 128
prefetch(xdp->data + L1_CACHE_BYTES);
 #endif
+   /* Note, we get here by enabling legacy-rx via:
+*
+*ethtool --set-priv-flags  legacy-rx on
+*
+* In this mode, we currently get 0 extra XDP headroom as
+* opposed to having legacy-rx off, where we process XDP
+* packets going to stack via ixgbevf_build_skb().
+*
+* For ixgbevf_construct_skb() mode it means that the
+* xdp->data_meta will always point to xdp->data, since
+* the helper cannot expand the head. Should this ever
+* changed in future for legacy-rx mode on, then lets also
+* add xdp->data_meta handling here.
+*/
 
/* allocate a skb to store the frags */
skb = napi_alloc_skb(_ring->q_vector->napi, IXGBEVF_RX_HDR_SIZE);
@@ -936,6 +950,7 @@ static struct sk_buff *ixgbevf_build_skb(struct 
ixgbevf_ring *rx_ring,
 struct xdp_buff *xdp,
 union ixgbe_adv_rx_desc *rx_desc)
 {
+   unsigned int metasize = xdp->data - xdp->data_meta;
 #if (PAGE_SIZE < 8192)
unsigned int truesize = ixgbevf_rx_pg_size(rx_ring) / 2;
 #else
@@ -945,10 +960,14 @@ static struct sk_buff *ixgbevf_build_skb(struct 
ixgbevf_ring *rx_ring,
 #endif
struct sk_buff *skb;
 
-   /* prefetch first cache line of first page */
-   prefetch(xdp->data);
+   /* Prefetch first cache line of first page. If xdp->data_meta
+* is unused, this points to xdp->data, otherwise, we likely
+* have a consumer accessing first few bytes of meta data,
+* and then actual data.
+*/
+   prefetch(xdp->data_meta);
 #if L1_CACHE_BYTES < 128
-   prefetch(xdp->data + L1_CACHE_BYTES);
+   prefetch(xdp->data_meta + L1_CACHE_BYTES);
 #endif
 
/* build an skb around the page buffer */
@@ -959,6 +978,8 @@ static struct sk_buff *ixgbevf_build_skb(struct 
ixgbevf_ring *rx_ring,
/* update pointers within the skb to store the data */
skb_reserve(skb, xdp->data - xdp->data_hard_start);
__skb_put(skb, xdp->data_end - xdp->data);
+   if (metasize)
+   skb_metadata_set(skb, metasize);
 
/* update buffer offset */
 #if (PAGE_SIZE < 8192)
@@ -1126,7 +1147,7 @@ static int ixgbevf_clean_rx_irq(struct ixgbevf_q_vector 
*q_vector,
if (!skb) {
xdp.data = page_address(rx_buffer->page) +
   rx_buffer->page_offset;
-   xdp_set_data_meta_invalid();
+   xdp.data_meta = xdp.data;
xdp.data_hard_start = xdp.data -
  ixgbevf_rx_offset(rx_ring);
xdp.data_end = xdp.data + size;
-- 
2.14.3



Re: [PATCH v2 bpf-next 5/8] bpf: introduce BPF_RAW_TRACEPOINT

2018-03-23 Thread Daniel Borkmann
On 03/22/2018 04:41 PM, Alexei Starovoitov wrote:
> On 3/22/18 2:43 AM, Daniel Borkmann wrote:
>> On 03/21/2018 07:54 PM, Alexei Starovoitov wrote:
>> [...]
>>> @@ -546,6 +556,53 @@ extern void ftrace_profile_free_filter(struct 
>>> perf_event *event);
>>>  void perf_trace_buf_update(void *record, u16 type);
>>>  void *perf_trace_buf_alloc(int size, struct pt_regs **regs, int *rctxp);
>>>
>>> +void bpf_trace_run1(struct bpf_prog *prog, u64 arg1);
>>> +void bpf_trace_run2(struct bpf_prog *prog, u64 arg1, u64 arg2);
>>> +void bpf_trace_run3(struct bpf_prog *prog, u64 arg1, u64 arg2,
>>> +    u64 arg3);
>>> +void bpf_trace_run4(struct bpf_prog *prog, u64 arg1, u64 arg2,
>>> +    u64 arg3, u64 arg4);
>>> +void bpf_trace_run5(struct bpf_prog *prog, u64 arg1, u64 arg2,
>>> +    u64 arg3, u64 arg4, u64 arg5);
>>> +void bpf_trace_run6(struct bpf_prog *prog, u64 arg1, u64 arg2,
>>> +    u64 arg3, u64 arg4, u64 arg5, u64 arg6);
>>> +void bpf_trace_run7(struct bpf_prog *prog, u64 arg1, u64 arg2,
>>> +    u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7);
>>> +void bpf_trace_run8(struct bpf_prog *prog, u64 arg1, u64 arg2,
>>> +    u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
>>> +    u64 arg8);
>>> +void bpf_trace_run9(struct bpf_prog *prog, u64 arg1, u64 arg2,
>>> +    u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
>>> +    u64 arg8, u64 arg9);
>>> +void bpf_trace_run10(struct bpf_prog *prog, u64 arg1, u64 arg2,
>>> + u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
>>> + u64 arg8, u64 arg9, u64 arg10);
>>> +void bpf_trace_run11(struct bpf_prog *prog, u64 arg1, u64 arg2,
>>> + u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
>>> + u64 arg8, u64 arg9, u64 arg10, u64 arg11);
>>> +void bpf_trace_run12(struct bpf_prog *prog, u64 arg1, u64 arg2,
>>> + u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
>>> + u64 arg8, u64 arg9, u64 arg10, u64 arg11, u64 arg12);
>>> +void bpf_trace_run13(struct bpf_prog *prog, u64 arg1, u64 arg2,
>>> + u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
>>> + u64 arg8, u64 arg9, u64 arg10, u64 arg11, u64 arg12,
>>> + u64 arg13);
>>> +void bpf_trace_run14(struct bpf_prog *prog, u64 arg1, u64 arg2,
>>> + u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
>>> + u64 arg8, u64 arg9, u64 arg10, u64 arg11, u64 arg12,
>>> + u64 arg13, u64 arg14);
>>> +void bpf_trace_run15(struct bpf_prog *prog, u64 arg1, u64 arg2,
>>> + u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
>>> + u64 arg8, u64 arg9, u64 arg10, u64 arg11, u64 arg12,
>>> + u64 arg13, u64 arg14, u64 arg15);
>>> +void bpf_trace_run16(struct bpf_prog *prog, u64 arg1, u64 arg2,
>>> + u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
>>> + u64 arg8, u64 arg9, u64 arg10, u64 arg11, u64 arg12,
>>> + u64 arg13, u64 arg14, u64 arg15, u64 arg16);
>>> +void bpf_trace_run17(struct bpf_prog *prog, u64 arg1, u64 arg2,
>>> + u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
>>> + u64 arg8, u64 arg9, u64 arg10, u64 arg11, u64 arg12,
>>> + u64 arg13, u64 arg14, u64 arg15, u64 arg16, u64 arg17);
>>>  void perf_trace_run_bpf_submit(void *raw_data, int size, int rctx,
>>>     struct trace_event_call *call, u64 count,
>>>     struct pt_regs *regs, struct hlist_head *head,
>> [...]
>>> @@ -896,3 +976,206 @@ int perf_event_query_prog_array(struct perf_event 
>>> *event, void __user *info)
>>>
>>>  return ret;
>>>  }
>>> +
>>> +static __always_inline
>>> +void __bpf_trace_run(struct bpf_prog *prog, u64 *args)
>>> +{
>>> +    rcu_read_lock();
>>> +    preempt_disable();
>>> +    (void) BPF_PROG_RUN(prog, args);
>>> +    preempt_enable();
>>> +    rcu_read_unlock();
>>> +}
>>> +
>>> +#define EVAL1(FN, X) FN(X)
>>> +#define EVAL2(FN, X, Y...) FN(X) EVAL1(FN, Y)
>>> +#define EVAL3(FN, X, Y...) FN(X) EVAL2(FN, Y)
>>> +#define EVAL4(FN, X, Y...) FN(X) EVAL3(FN, Y)
>>> +#define EVAL5(FN, X, Y...) FN(X) EVAL4(FN, Y)
>>> +#define EVAL6(FN, X, Y...) FN(X) EVAL5(FN, Y)
>>> +
>>> +#define COPY(X) args[X - 1] = arg##X;
>>> +
>>> +void bpf_trace_run1(struct bpf_prog *prog, u64 arg1)
>>> +{
>>> +    u64 args[1];
>>> +
>>> +    EVAL1(COPY, 1);
>>> +    __bpf_trace_run(prog, args);
>>> +}
>>> +EXPORT_SYMBOL_GPL(bpf_trace_run1);
>>> +void bpf_trace_run2(struct bpf_prog *prog, u64 arg1, u64 arg2)
>>> +{
>>> +    u64 args[2];
>>> +
>>> +    EVAL2(COPY, 1, 2);
>>> +    __bpf_trace_run(prog, args);
>>> +}
>>> +EXPORT_SYMBOL_GPL(bpf_trace_run2);
>>> +void bpf_trace_run3(struct bpf_prog *prog, u64 arg1, u64 arg2,
>>> +    u64 arg3)
>>> +{
>>> +    u64 args[3];
>>> +
>>> +    EVAL3(COPY, 1, 2, 3);
>>> +    __bpf_trace_run(prog, args);
>>> +}
>>> +EXPORT_SYMBOL_GPL(bpf_trace_run3);
>>> +void bpf_trace_run4(struct 

Re: [QUESTION] Mainline support for B43_PHY_AC wifi cards

2018-03-23 Thread Rafał Miłecki
On 23 March 2018 at 15:09, Juri Lelli  wrote:
> On 23/03/18 14:43, Rafał Miłecki wrote:
>> Hi,
>>
>> On 23 March 2018 at 10:47, Juri Lelli  wrote:
>> > I've got a Dell XPS 13 9343/0TM99H (BIOS A15 01/23/2018) mounting a
>> > BCM4352 802.11ac (rev 03) wireless card and so far I've been using it on
>> > Fedora with broadcom-wl package (which I believe installs Broadcom's STA
>> > driver?). It works good apart from occasional hiccups after suspend.
>> >
>> > I'd like to get rid of that dependency (you can understand that it's
>> > particularly annoying when testing mainline kernels), but I found out
>> > that support for my card is BROKEN in mainline [1]. Just to see what
>> > happens, I forcibly enabled it witnessing that it indeed crashes like
>> > below as Kconfig warns. :)
>> >
>> >  bcma: bus0: Found chip with id 0x4352, rev 0x03 and package 0x00
>> >  bcma: bus0: Core 0 found: ChipCommon (manuf 0x4BF, id 0x800, rev 0x2B, 
>> > class 0x0)
>> >  bcma: bus0: Core 1 found: IEEE 802.11 (manuf 0x4BF, id 0x812, rev 0x2A, 
>> > class 0x0)
>> >  bcma: bus0: Core 2 found: ARM CR4 (manuf 0x4BF, id 0x83E, rev 0x02, class 
>> > 0x0)
>> >  bcma: bus0: Core 3 found: PCIe Gen2 (manuf 0x4BF, id 0x83C, rev 0x01, 
>> > class 0x0)
>> >  bcma: bus0: Core 4 found: USB 2.0 Device (manuf 0x4BF, id 0x81A, rev 
>> > 0x11, class 0x0)
>> >  bcma: Unsupported SPROM revision: 11
>> >  bcma: bus0: Invalid SPROM read from the PCIe card, trying to use fallback 
>> > SPROM
>> >  bcma: bus0: Using fallback SPROM failed (err -2)
>> >  bcma: bus0: No SPROM available
>> >  bcma: bus0: Bus registered
>> >  b43-phy0: Broadcom 4352 WLAN found (core revision 42)
>> >  b43-phy0: Found PHY: Analog 12, Type 11 (AC), Revision 1
>> >  b43-phy0: Found Radio: Manuf 0x17F, ID 0x2069, Revision 4, Version 0
>> >  BUG: unable to handle kernel NULL pointer dereference at 
>>
>> This isn't really useful without a full backtrace.
>
> Sure. I cut it here because I didn't expect people to debug what is
> already known to be broken (but still it seemed to carry useful
> information about the hw). :)

Please paste the remaining part if you still got it.


>> > So, question: is replacing my card the only way I can get rid of this
>> > downstream dependency? :(
>>
>> It's definitely the cheapest way. Getting AC PHY into anything usable
>> (proper setup that will allow Tx & Rx anything) would probably take
>> weeks or months of development. I'm not even going to estimate cost of
>> adding support for 802.11n and 802.11ac features. I was the last
>> person actively working on b43, right now I spend my free time on
>> other hobby projects. Few people were planning to help but it seems it
>> never worked out for them.
>
> I see. Just wondering why even if Broadcom's STA solution seems to work
> fine, it is not mainline. Maybe a maintenance problem? But Fedora ships
> with very recent kernels, so I'd expect the driver to work with mainline
> (I tried compiling that against mainline, but I got errors that I didn't
> spend time figuring out how to fix).
>
> Do you know what's the deal w.r.t. the STA driver?

Driver being closed source and company not willing to open source it
is usually a big problem getting it mainline...

-- 
Rafał


[PATCH 4/4] drivers/net: Use octal not symbolic permissions

2018-03-23 Thread Joe Perches
Prefer the direct use of octal for permissions.

Done with checkpatch -f --types=SYMBOLIC_PERMS --fix-inplace
and some typing.

Miscellanea:

o Whitespace neatening around these conversions.

Signed-off-by: Joe Perches 
---
 drivers/net/bonding/bond_procfs.c  |  2 +-
 drivers/net/bonding/bond_sysfs.c   | 73 +-
 drivers/net/bonding/bond_sysfs_slave.c |  4 +-
 drivers/net/caif/caif_serial.c | 32 +++
 drivers/net/caif/caif_spi.c| 16 
 drivers/net/caif/caif_virtio.c | 16 
 drivers/net/can/at91_can.c |  3 +-
 drivers/net/can/cc770/cc770.c  |  4 +-
 drivers/net/can/cc770/cc770_isa.c  | 16 
 drivers/net/can/grcan.c|  4 +-
 drivers/net/can/janz-ican3.c   |  6 +--
 drivers/net/can/sja1000/sja1000_isa.c  | 14 +++
 drivers/net/can/softing/softing_main.c |  4 +-
 drivers/net/can/spi/mcp251x.c  |  2 +-
 drivers/net/can/usb/esd_usb2.c |  6 +--
 drivers/net/can/vcan.c |  2 +-
 drivers/net/hamradio/bpqether.c|  3 +-
 drivers/net/hamradio/yam.c |  2 +-
 drivers/net/hyperv/netvsc_drv.c|  4 +-
 drivers/net/ieee802154/at86rf230.c |  2 +-
 drivers/net/phy/spi_ks8995.c   |  2 +-
 drivers/net/ppp/ppp_generic.c  |  2 +-
 drivers/net/ppp/pppoe.c|  2 +-
 drivers/net/usb/cdc_ncm.c  | 12 +++---
 drivers/net/usb/hso.c  |  8 ++--
 drivers/net/xen-netback/xenbus.c   |  4 +-
 drivers/net/xen-netfront.c |  6 +--
 27 files changed, 124 insertions(+), 127 deletions(-)

diff --git a/drivers/net/bonding/bond_procfs.c 
b/drivers/net/bonding/bond_procfs.c
index f7799321dffb..01059f1a7bca 100644
--- a/drivers/net/bonding/bond_procfs.c
+++ b/drivers/net/bonding/bond_procfs.c
@@ -287,7 +287,7 @@ void bond_create_proc_entry(struct bonding *bond)
 
if (bn->proc_dir) {
bond->proc_entry = proc_create_data(bond_dev->name,
-   S_IRUGO, bn->proc_dir,
+   0444, bn->proc_dir,
_info_fops, bond);
if (bond->proc_entry == NULL)
netdev_warn(bond_dev, "Cannot create /proc/net/%s/%s\n",
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 040b493f60ae..6096440e96ea 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -147,7 +147,7 @@ static ssize_t bonding_store_bonds(struct class *cls,
 static const struct class_attribute class_attr_bonding_masters = {
.attr = {
.name = "bonding_masters",
-   .mode = S_IWUSR | S_IRUGO,
+   .mode = 0644,
},
.show = bonding_show_bonds,
.store = bonding_store_bonds,
@@ -202,7 +202,7 @@ static ssize_t bonding_show_slaves(struct device *d,
 
return res;
 }
-static DEVICE_ATTR(slaves, S_IRUGO | S_IWUSR, bonding_show_slaves,
+static DEVICE_ATTR(slaves, 0644, bonding_show_slaves,
   bonding_sysfs_store_option);
 
 /* Show the bonding mode. */
@@ -216,8 +216,7 @@ static ssize_t bonding_show_mode(struct device *d,
 
return sprintf(buf, "%s %d\n", val->string, BOND_MODE(bond));
 }
-static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR,
-  bonding_show_mode, bonding_sysfs_store_option);
+static DEVICE_ATTR(mode, 0644, bonding_show_mode, bonding_sysfs_store_option);
 
 /* Show the bonding transmit hash method. */
 static ssize_t bonding_show_xmit_hash(struct device *d,
@@ -231,7 +230,7 @@ static ssize_t bonding_show_xmit_hash(struct device *d,
 
return sprintf(buf, "%s %d\n", val->string, bond->params.xmit_policy);
 }
-static DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(xmit_hash_policy, 0644,
   bonding_show_xmit_hash, bonding_sysfs_store_option);
 
 /* Show arp_validate. */
@@ -247,7 +246,7 @@ static ssize_t bonding_show_arp_validate(struct device *d,
 
return sprintf(buf, "%s %d\n", val->string, bond->params.arp_validate);
 }
-static DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate,
+static DEVICE_ATTR(arp_validate, 0644, bonding_show_arp_validate,
   bonding_sysfs_store_option);
 
 /* Show arp_all_targets. */
@@ -263,7 +262,7 @@ static ssize_t bonding_show_arp_all_targets(struct device 
*d,
return sprintf(buf, "%s %d\n",
   val->string, bond->params.arp_all_targets);
 }
-static DEVICE_ATTR(arp_all_targets, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(arp_all_targets, 0644,
   bonding_show_arp_all_targets, bonding_sysfs_store_option);
 
 /* Show fail_over_mac. */
@@ -279,7 +278,7 @@ static ssize_t bonding_show_fail_over_mac(struct device *d,
 
return sprintf(buf, "%s %d\n", val->string, 

[PATCH 2/4] wireless: Use octal not symbolic permissions

2018-03-23 Thread Joe Perches
Prefer the direct use of octal for permissions.

Done with checkpatch -f --types=SYMBOLIC_PERMS --fix-inplace
and some typing.

Miscellanea:

o Whitespace neatening around these conversions.

Signed-off-by: Joe Perches 
---
 drivers/net/wireless/ath/ath5k/base.c  |   6 +-
 drivers/net/wireless/ath/ath5k/debug.c |  37 +++
 drivers/net/wireless/ath/ath5k/sysfs.c |   8 +-
 drivers/net/wireless/ath/ath6kl/debug.c|  43 
 drivers/net/wireless/ath/ath9k/common-debug.c  |   9 +-
 drivers/net/wireless/ath/ath9k/common-spectral.c   |  10 +-
 drivers/net/wireless/ath/ath9k/debug.c |  40 
 drivers/net/wireless/ath/ath9k/debug_sta.c |   6 +-
 drivers/net/wireless/ath/ath9k/dfs_debug.c |   4 +-
 drivers/net/wireless/ath/ath9k/htc_drv_debug.c |  16 +--
 drivers/net/wireless/ath/ath9k/tx99.c  |   4 +-
 drivers/net/wireless/ath/carl9170/debug.c  |   8 +-
 drivers/net/wireless/ath/carl9170/main.c   |   4 +-
 drivers/net/wireless/ath/wcn36xx/debug.c   |   5 +-
 .../wireless/broadcom/brcm80211/brcmfmac/common.c  |   6 +-
 .../wireless/broadcom/brcm80211/brcmsmac/debug.c   |   2 +-
 .../broadcom/brcm80211/brcmsmac/mac80211_if.c  |   2 +-
 drivers/net/wireless/cisco/airo.c  |   6 +-
 drivers/net/wireless/intel/ipw2x00/ipw2100.c   |  29 +++---
 drivers/net/wireless/intel/ipw2x00/ipw2200.c   |  51 +-
 drivers/net/wireless/intel/ipw2x00/libipw_module.c |   2 +-
 drivers/net/wireless/intel/iwlegacy/3945-mac.c |  35 +++
 drivers/net/wireless/intel/iwlegacy/4965-mac.c |  19 ++--
 drivers/net/wireless/intel/iwlegacy/4965-rs.c  |   8 +-
 drivers/net/wireless/intel/iwlegacy/common.c   |   4 +-
 drivers/net/wireless/intel/iwlegacy/debug.c|  58 ++-
 drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c   |  78 +++
 drivers/net/wireless/intel/iwlwifi/dvm/rs.c|  16 +--
 drivers/net/wireless/intel/iwlwifi/fw/debugfs.c|   2 +-
 drivers/net/wireless/intel/iwlwifi/iwl-drv.c   |  43 
 .../net/wireless/intel/iwlwifi/mvm/debugfs-vif.c   |  40 +++-
 drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c   | 110 ++---
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c   |   6 +-
 drivers/net/wireless/intel/iwlwifi/mvm/rs.c|  12 +--
 drivers/net/wireless/intel/iwlwifi/pcie/trans.c|  12 +--
 drivers/net/wireless/intersil/p54/main.c   |   2 +-
 drivers/net/wireless/mediatek/mt76/debugfs.c   |  10 +-
 .../net/wireless/mediatek/mt76/mt76x2_debugfs.c|   8 +-
 drivers/net/wireless/mediatek/mt7601u/debugfs.c|  16 ++-
 drivers/net/wireless/ralink/rt2x00/rt2500usb.c |   2 +-
 drivers/net/wireless/ralink/rt2x00/rt2800pci.c |   2 +-
 drivers/net/wireless/ralink/rt2x00/rt2800soc.c |   2 +-
 drivers/net/wireless/ralink/rt2x00/rt2800usb.c |   2 +-
 drivers/net/wireless/ralink/rt2x00/rt2x00debug.c   |  64 ++--
 drivers/net/wireless/ralink/rt2x00/rt61pci.c   |   2 +-
 drivers/net/wireless/ralink/rt2x00/rt73usb.c   |   2 +-
 drivers/net/wireless/ray_cs.c  |   8 +-
 drivers/net/wireless/st/cw1200/debug.c |   6 +-
 drivers/net/wireless/st/cw1200/main.c  |   2 +-
 drivers/net/wireless/ti/wl18xx/main.c  |  27 +++--
 drivers/net/wireless/ti/wlcore/main.c  |   8 +-
 drivers/net/wireless/ti/wlcore/sdio.c  |   2 +-
 drivers/net/wireless/ti/wlcore/sysfs.c |   7 +-
 53 files changed, 427 insertions(+), 486 deletions(-)

diff --git a/drivers/net/wireless/ath/ath5k/base.c 
b/drivers/net/wireless/ath/ath5k/base.c
index 527afcf39246..a2351ef45ae0 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -73,16 +73,16 @@
 #include "trace.h"
 
 bool ath5k_modparam_nohwcrypt;
-module_param_named(nohwcrypt, ath5k_modparam_nohwcrypt, bool, S_IRUGO);
+module_param_named(nohwcrypt, ath5k_modparam_nohwcrypt, bool, 0444);
 MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
 
 static bool modparam_fastchanswitch;
-module_param_named(fastchanswitch, modparam_fastchanswitch, bool, S_IRUGO);
+module_param_named(fastchanswitch, modparam_fastchanswitch, bool, 0444);
 MODULE_PARM_DESC(fastchanswitch, "Enable fast channel switching for 
AR2413/AR5413 radios.");
 
 static bool ath5k_modparam_no_hw_rfkill_switch;
 module_param_named(no_hw_rfkill_switch, ath5k_modparam_no_hw_rfkill_switch,
-   bool, S_IRUGO);
+  bool, 0444);
 MODULE_PARM_DESC(no_hw_rfkill_switch, "Ignore the GPIO RFKill switch state");
 
 
diff --git a/drivers/net/wireless/ath/ath5k/debug.c 
b/drivers/net/wireless/ath/ath5k/debug.c
index bd7f6d7b199e..3513bbec4639 100644
--- a/drivers/net/wireless/ath/ath5k/debug.c
+++ b/drivers/net/wireless/ath/ath5k/debug.c
@@ -1004,32 +1004,17 @@ 

[PATCH 3/4] net: Use octal not symbolic permissions

2018-03-23 Thread Joe Perches
Prefer the direct use of octal for permissions.

Done with checkpatch -f --types=SYMBOLIC_PERMS --fix-inplace
and some typing.

Miscellanea:

o Whitespace neatening around these conversions.

Signed-off-by: Joe Perches 
---
 net/8021q/vlanproc.c   |  6 ++---
 net/appletalk/atalk_proc.c |  8 +++---
 net/atm/atm_sysfs.c| 12 -
 net/atm/clip.c |  2 +-
 net/atm/lec.c  |  2 +-
 net/atm/proc.c |  2 +-
 net/ax25/af_ax25.c |  6 ++---
 net/bluetooth/rfcomm/tty.c |  4 +--
 net/bridge/br_sysfs_br.c   |  2 +-
 net/bridge/br_sysfs_if.c   | 36 -
 net/can/af_can.c   |  2 +-
 net/can/gw.c   |  2 +-
 net/ceph/ceph_common.c |  2 +-
 net/core/net-procfs.c  |  6 ++---
 net/core/net-sysfs.c   | 12 -
 net/core/sock.c|  2 +-
 net/decnet/af_decnet.c |  2 +-
 net/decnet/dn_dev.c|  2 +-
 net/decnet/dn_neigh.c  |  2 +-
 net/decnet/dn_route.c  |  2 +-
 net/dns_resolver/dns_key.c |  2 +-
 net/ipv4/arp.c |  2 +-
 net/ipv4/fib_trie.c|  6 ++---
 net/ipv4/igmp.c|  4 +--
 net/ipv4/ipconfig.c|  2 +-
 net/ipv4/netfilter/ipt_CLUSTERIP.c |  2 +-
 net/ipv4/ping.c|  2 +-
 net/ipv4/proc.c|  6 ++---
 net/ipv4/raw.c |  2 +-
 net/ipv4/route.c   |  4 +--
 net/ipv4/tcp_ipv4.c|  2 +-
 net/ipv4/udp.c |  2 +-
 net/ipv6/addrconf.c|  2 +-
 net/ipv6/anycast.c |  2 +-
 net/ipv6/ip6_flowlabel.c   |  2 +-
 net/ipv6/mcast.c   |  4 +--
 net/ipv6/proc.c|  6 ++---
 net/ipv6/raw.c |  2 +-
 net/ipv6/route.c   |  2 +-
 net/kcm/kcmproc.c  |  4 +--
 net/l2tp/l2tp_ppp.c|  2 +-
 net/llc/llc_proc.c |  4 +--
 net/mac80211/rc80211_minstrel.c|  2 +-
 net/mac80211/rc80211_minstrel_debugfs.c|  8 +++---
 net/mac80211/rc80211_minstrel_ht_debugfs.c |  8 +++---
 net/netfilter/nf_conntrack_netbios_ns.c|  2 +-
 net/netfilter/nf_conntrack_snmp.c  |  2 +-
 net/netfilter/nf_conntrack_standalone.c|  2 +-
 net/netfilter/nf_log.c |  2 +-
 net/netfilter/nf_synproxy_core.c   |  2 +-
 net/netfilter/xt_IDLETIMER.c   |  2 +-
 net/netfilter/xt_recent.c  |  4 +--
 net/netrom/af_netrom.c |  6 ++---
 net/rose/af_rose.c |  8 +++---
 net/rxrpc/af_rxrpc.c   |  2 +-
 net/sctp/proc.c| 16 ++--
 net/sunrpc/auth_gss/svcauth_gss.c  |  2 +-
 net/sunrpc/cache.c | 10 +++
 net/sunrpc/debugfs.c   |  6 ++---
 net/sunrpc/rpc_pipe.c  | 42 +++---
 net/wireless/wext-proc.c   |  2 +-
 net/x25/x25_proc.c | 12 -
 net/xfrm/xfrm_proc.c   |  2 +-
 63 files changed, 161 insertions(+), 161 deletions(-)

diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index a662ccc166df..a627a5db2125 100644
--- a/net/8021q/vlanproc.c
+++ b/net/8021q/vlanproc.c
@@ -148,8 +148,8 @@ int __net_init vlan_proc_init(struct net *net)
if (!vn->proc_vlan_dir)
goto err;
 
-   vn->proc_vlan_conf = proc_create(name_conf, S_IFREG|S_IRUSR|S_IWUSR,
-vn->proc_vlan_dir, _fops);
+   vn->proc_vlan_conf = proc_create(name_conf, S_IFREG | 0600,
+vn->proc_vlan_dir, _fops);
if (!vn->proc_vlan_conf)
goto err;
return 0;
@@ -172,7 +172,7 @@ int vlan_proc_add_dev(struct net_device *vlandev)
if (!strcmp(vlandev->name, name_conf))
return -EINVAL;
vlan->dent =
-   proc_create_data(vlandev->name, S_IFREG|S_IRUSR|S_IWUSR,
+   proc_create_data(vlandev->name, S_IFREG | 0600,
 vn->proc_vlan_dir, _fops, vlandev);
if (!vlan->dent)
return -ENOBUFS;
diff --git a/net/appletalk/atalk_proc.c b/net/appletalk/atalk_proc.c
index a3bf9d519193..7214aea14cb3 100644
--- a/net/appletalk/atalk_proc.c
+++ b/net/appletalk/atalk_proc.c
@@ -257,22 +257,22 @@ int __init 

[PATCH 0/4] net: drivers/net: Use octal permissions

2018-03-23 Thread Joe Perches
Using octal and not symbolic permissions is preferred by many as
more readable.

https://lkml.org/lkml/2016/8/2/1945

Rather than getting these piecemeal, just do them all.
Done with checkpatch and some typing.

Joe Perches (4):
  ethernet: Use octal not symbolic permissions
  wireless: Use octal not symbolic permissions
  net: Use octal not symbolic permissions
  drivers/net: Use octal not symbolic permissions

 drivers/net/bonding/bond_procfs.c  |   2 +-
 drivers/net/bonding/bond_sysfs.c   |  73 +++---
 drivers/net/bonding/bond_sysfs_slave.c |   4 +-
 drivers/net/caif/caif_serial.c |  32 +++---
 drivers/net/caif/caif_spi.c|  16 +--
 drivers/net/caif/caif_virtio.c |  16 +--
 drivers/net/can/at91_can.c |   3 +-
 drivers/net/can/cc770/cc770.c  |   4 +-
 drivers/net/can/cc770/cc770_isa.c  |  16 +--
 drivers/net/can/grcan.c|   4 +-
 drivers/net/can/janz-ican3.c   |   6 +-
 drivers/net/can/sja1000/sja1000_isa.c  |  14 +--
 drivers/net/can/softing/softing_main.c |   4 +-
 drivers/net/can/spi/mcp251x.c  |   2 +-
 drivers/net/can/usb/esd_usb2.c |   6 +-
 drivers/net/can/vcan.c |   2 +-
 drivers/net/ethernet/8390/apne.c   |   2 +-
 drivers/net/ethernet/8390/lib8390.c|   2 +-
 drivers/net/ethernet/8390/ne.c |   2 +-
 drivers/net/ethernet/8390/ne2k-pci.c   |   2 +-
 drivers/net/ethernet/8390/smc-ultra.c  |   2 +-
 drivers/net/ethernet/8390/stnic.c  |   2 +-
 drivers/net/ethernet/8390/wd.c |   2 +-
 drivers/net/ethernet/altera/altera_tse_main.c  |   6 +-
 drivers/net/ethernet/amd/xgbe/xgbe-drv.c   |  10 +-
 drivers/net/ethernet/amd/xgbe/xgbe-main.c  |   2 +-
 drivers/net/ethernet/broadcom/bnx2.c   |   2 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c   |  12 +--
 drivers/net/ethernet/broadcom/sb1250-mac.c |  10 +-
 drivers/net/ethernet/broadcom/tg3.c|   6 +-
 drivers/net/ethernet/brocade/bna/bnad.c|   2 +-
 drivers/net/ethernet/brocade/bna/bnad_debugfs.c|  10 +-
 drivers/net/ethernet/cavium/thunder/nicvf_main.c   |   2 +-
 drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c|   6 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 112 ++---
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c|  10 +-
 drivers/net/ethernet/ec_bhf.c  |   2 +-
 drivers/net/ethernet/emulex/benet/be_main.c|   6 +-
 drivers/net/ethernet/ibm/ehea/ehea_main.c  |   7 +-
 drivers/net/ethernet/ibm/ibmveth.c |   2 +-
 drivers/net/ethernet/intel/igb/igb_hwmon.c |   2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c |   2 +-
 drivers/net/ethernet/marvell/mvneta.c  |   8 +-
 drivers/net/ethernet/marvell/skge.c|   2 +-
 drivers/net/ethernet/marvell/sky2.c|   2 +-
 drivers/net/ethernet/mellanox/mlx4/main.c  |  16 +--
 drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c   |  10 +-
 drivers/net/ethernet/myricom/myri10ge/myri10ge.c   |  32 +++---
 .../net/ethernet/netronome/nfp/nfp_net_debugfs.c   |   6 +-
 .../net/ethernet/qlogic/netxen/netxen_nic_main.c   |  14 +--
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c  |  30 +++---
 drivers/net/ethernet/qualcomm/qca_debug.c  |   2 +-
 drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c|   4 +-
 drivers/net/ethernet/sfc/mcdi_mon.c|   2 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  |  26 ++---
 drivers/net/ethernet/sun/niu.c |  10 +-
 drivers/net/hamradio/bpqether.c|   3 +-
 drivers/net/hamradio/yam.c |   2 +-
 drivers/net/hyperv/netvsc_drv.c|   4 +-
 drivers/net/ieee802154/at86rf230.c |   2 +-
 drivers/net/phy/spi_ks8995.c   |   2 +-
 drivers/net/ppp/ppp_generic.c  |   2 +-
 drivers/net/ppp/pppoe.c|   2 +-
 drivers/net/usb/cdc_ncm.c  |  12 +--
 drivers/net/usb/hso.c  |   8 +-
 drivers/net/wireless/ath/ath5k/base.c  |   6 +-
 drivers/net/wireless/ath/ath5k/debug.c |  37 ++-
 drivers/net/wireless/ath/ath5k/sysfs.c |   8 +-
 drivers/net/wireless/ath/ath6kl/debug.c|  43 
 drivers/net/wireless/ath/ath9k/common-debug.c  |   9 +-
 drivers/net/wireless/ath/ath9k/common-spectral.c   |  10 +-
 drivers/net/wireless/ath/ath9k/debug.c |  40 
 drivers/net/wireless/ath/ath9k/debug_sta.c |   6 +-
 drivers/net/wireless/ath/ath9k/dfs_debug.c |   4 

[PATCH][next] batman-adv: don't pass a NULL hard_iface to batadv_hardif_put

2018-03-23 Thread Colin King
From: Colin Ian King 

In the case where hard_iface is NULL, the error path may pass a null
pointer to batadv_hardif_put causing a null pointer dereference error.
Avoid this by only calling the function if  hard_iface not null.

Detected by CoverityScan, CID#1466456 ("Explicit null dereferenced")

Fixes: 53dd9a68ba68 ("batman-adv: add multicast flags netlink support")
Signed-off-by: Colin Ian King 
---
 net/batman-adv/multicast.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index de3a055f7dd8..bd0ea374d043 100644
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -1536,7 +1536,7 @@ batadv_mcast_netlink_get_primary(struct netlink_callback 
*cb,
 
if (!ret && primary_if)
*primary_if = hard_iface;
-   else
+   else if (hard_iface)
batadv_hardif_put(hard_iface);
 
return ret;
-- 
2.15.1



[net-next 15/15] net/mlx5e: Add VLAN offload features to hw_enc_features

2018-03-23 Thread Saeed Mahameed
From: Aviv Heller 

We support outer VLAN offload in driver and HW regardless of whether
an encapsulation is present in the next headers.

Exposing this in hw_enc_features will allow us to offload outer VLANs
in cases where encapsulation protocols like VXLAN and IPsec are used.

Signed-off-by: Aviv Heller 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index fb936a978f20..1d36d7569f44 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -4106,6 +4106,9 @@ static void mlx5e_build_nic_netdev(struct net_device 
*netdev)
netdev->vlan_features|= NETIF_F_RXCSUM;
netdev->vlan_features|= NETIF_F_RXHASH;
 
+   netdev->hw_enc_features  |= NETIF_F_HW_VLAN_CTAG_TX;
+   netdev->hw_enc_features  |= NETIF_F_HW_VLAN_CTAG_RX;
+
if (!!MLX5_CAP_ETH(mdev, lro_cap))
netdev->vlan_features|= NETIF_F_LRO;
 
-- 
2.14.3



[net-next 05/15] net/mlx5e: Add vnic steering drop statistics

2018-03-23 Thread Saeed Mahameed
From: Moshe Shemesh 

Added the following packets drop counter:
Rx steering missed dropped packets - counts packets which were dropped
due to miss on NIC rx steering rules.
This counter will be shown on ethtool as a new counter called
rx_steer_missed_packets.

Signed-off-by: Moshe Shemesh 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_stats.c | 65 ++
 drivers/net/ethernet/mellanox/mlx5/core/en_stats.h |  5 ++
 include/linux/mlx5/mlx5_ifc.h  |  3 +-
 3 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
index 2553c58dcf1c..552510c03ef2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
@@ -211,6 +211,65 @@ static void mlx5e_grp_q_update_stats(struct mlx5e_priv 
*priv)
qcnt->rx_out_of_buffer = MLX5_GET(query_q_counter_out, out, 
out_of_buffer);
 }
 
+#define VNIC_ENV_OFF(c) MLX5_BYTE_OFF(query_vnic_env_out, c)
+static const struct counter_desc vnic_env_stats_desc[] = {
+   { "rx_steer_missed_packets",
+   VNIC_ENV_OFF(vport_env.nic_receive_steering_discard) },
+};
+
+#define NUM_VNIC_ENV_COUNTERS  ARRAY_SIZE(vnic_env_stats_desc)
+
+static int mlx5e_grp_vnic_env_get_num_stats(struct mlx5e_priv *priv)
+{
+   return MLX5_CAP_GEN(priv->mdev, nic_receive_steering_discard) ?
+   NUM_VNIC_ENV_COUNTERS : 0;
+}
+
+static int mlx5e_grp_vnic_env_fill_strings(struct mlx5e_priv *priv, u8 *data,
+  int idx)
+{
+   int i;
+
+   if (!MLX5_CAP_GEN(priv->mdev, nic_receive_steering_discard))
+   return idx;
+
+   for (i = 0; i < NUM_VNIC_ENV_COUNTERS; i++)
+   strcpy(data + (idx++) * ETH_GSTRING_LEN,
+  vnic_env_stats_desc[i].format);
+   return idx;
+}
+
+static int mlx5e_grp_vnic_env_fill_stats(struct mlx5e_priv *priv, u64 *data,
+int idx)
+{
+   int i;
+
+   if (!MLX5_CAP_GEN(priv->mdev, nic_receive_steering_discard))
+   return idx;
+
+   for (i = 0; i < NUM_VNIC_ENV_COUNTERS; i++)
+   data[idx++] = 
MLX5E_READ_CTR64_BE(priv->stats.vnic.query_vnic_env_out,
+ vnic_env_stats_desc, i);
+   return idx;
+}
+
+static void mlx5e_grp_vnic_env_update_stats(struct mlx5e_priv *priv)
+{
+   u32 *out = (u32 *)priv->stats.vnic.query_vnic_env_out;
+   int outlen = MLX5_ST_SZ_BYTES(query_vnic_env_out);
+   u32 in[MLX5_ST_SZ_DW(query_vnic_env_in)] = {0};
+   struct mlx5_core_dev *mdev = priv->mdev;
+
+   if (!MLX5_CAP_GEN(priv->mdev, nic_receive_steering_discard))
+   return;
+
+   MLX5_SET(query_vnic_env_in, in, opcode,
+MLX5_CMD_OP_QUERY_VNIC_ENV);
+   MLX5_SET(query_vnic_env_in, in, op_mod, 0);
+   MLX5_SET(query_vnic_env_in, in, other_vport, 0);
+   mlx5_cmd_exec(mdev, in, sizeof(in), out, outlen);
+}
+
 #define VPORT_COUNTER_OFF(c) MLX5_BYTE_OFF(query_vport_counter_out, c)
 static const struct counter_desc vport_stats_desc[] = {
{ "rx_vport_unicast_packets",
@@ -,6 +1170,12 @@ const struct mlx5e_stats_grp mlx5e_stats_grps[] = {
.update_stats_mask = MLX5E_NDO_UPDATE_STATS,
.update_stats = mlx5e_grp_q_update_stats,
},
+   {
+   .get_num_stats = mlx5e_grp_vnic_env_get_num_stats,
+   .fill_strings = mlx5e_grp_vnic_env_fill_strings,
+   .fill_stats = mlx5e_grp_vnic_env_fill_stats,
+   .update_stats = mlx5e_grp_vnic_env_update_stats,
+   },
{
.get_num_stats = mlx5e_grp_vport_get_num_stats,
.fill_strings = mlx5e_grp_vport_fill_strings,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h 
b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
index 0b3320a2b072..847388ff8ca8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
@@ -99,6 +99,10 @@ struct mlx5e_qcounter_stats {
u32 rx_out_of_buffer;
 };
 
+struct mlx5e_vnic_env_stats {
+   __be64 query_vnic_env_out[MLX5_ST_SZ_QW(query_vnic_env_out)];
+};
+
 #define VPORT_COUNTER_GET(vstats, c) MLX5_GET64(query_vport_counter_out, \
vstats->query_vport_out, c)
 
@@ -201,6 +205,7 @@ struct mlx5e_ch_stats {
 struct mlx5e_stats {
struct mlx5e_sw_stats sw;
struct mlx5e_qcounter_stats qcnt;
+   struct mlx5e_vnic_env_stats vnic;
struct mlx5e_vport_stats vport;
struct mlx5e_pport_stats pport;
struct rtnl_link_stats64 vf_vport;
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 52e373dd2679..9202113f552c 

[net-next 03/15] net/mlx5e: PFC stall prevention support

2018-03-23 Thread Saeed Mahameed
From: Inbar Karmy 

Implement set/get functions to configure PFC stall prevention
timeout by tunables api through ethtool.
By default the stall prevention timeout is configured to 8 sec.
Timeout range is: 80-8000 msec.
Enabling stall prevention without a specific timeout will set
the timeout to 100 msec.

Signed-off-by: Inbar Karmy 
Signed-off-by: Saeed Mahameed 
---
 .../net/ethernet/mellanox/mlx5/core/en_ethtool.c   | 57 +++
 drivers/net/ethernet/mellanox/mlx5/core/port.c | 64 +++---
 include/linux/mlx5/mlx5_ifc.h  | 17 --
 include/linux/mlx5/port.h  |  6 ++
 4 files changed, 132 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index cc8048f68f11..62061fd23143 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -1066,6 +1066,57 @@ static int mlx5e_get_rxnfc(struct net_device *netdev,
return err;
 }
 
+#define MLX5E_PFC_PREVEN_AUTO_TOUT_MSEC100
+#define MLX5E_PFC_PREVEN_TOUT_MAX_MSEC 8000
+#define MLX5E_PFC_PREVEN_MINOR_PRECENT 85
+#define MLX5E_PFC_PREVEN_TOUT_MIN_MSEC 80
+#define MLX5E_DEVICE_STALL_MINOR_WATERMARK(critical_tout) \
+   max_t(u16, MLX5E_PFC_PREVEN_TOUT_MIN_MSEC, \
+ (critical_tout * MLX5E_PFC_PREVEN_MINOR_PRECENT) / 100)
+
+static int mlx5e_get_pfc_prevention_tout(struct net_device *netdev,
+u16 *pfc_prevention_tout)
+{
+   struct mlx5e_priv *priv= netdev_priv(netdev);
+   struct mlx5_core_dev *mdev = priv->mdev;
+
+   if (!MLX5_CAP_PCAM_FEATURE((priv)->mdev, pfcc_mask) ||
+   !MLX5_CAP_DEBUG((priv)->mdev, stall_detect))
+   return -EOPNOTSUPP;
+
+   return mlx5_query_port_stall_watermark(mdev, pfc_prevention_tout, NULL);
+}
+
+static int mlx5e_set_pfc_prevention_tout(struct net_device *netdev,
+u16 pfc_preven)
+{
+   struct mlx5e_priv *priv = netdev_priv(netdev);
+   struct mlx5_core_dev *mdev = priv->mdev;
+   u16 critical_tout;
+   u16 minor;
+
+   if (!MLX5_CAP_PCAM_FEATURE((priv)->mdev, pfcc_mask) ||
+   !MLX5_CAP_DEBUG((priv)->mdev, stall_detect))
+   return -EOPNOTSUPP;
+
+   critical_tout = (pfc_preven == PFC_STORM_PREVENTION_AUTO) ?
+   MLX5E_PFC_PREVEN_AUTO_TOUT_MSEC :
+   pfc_preven;
+
+   if (critical_tout != PFC_STORM_PREVENTION_DISABLE &&
+   (critical_tout > MLX5E_PFC_PREVEN_TOUT_MAX_MSEC ||
+critical_tout < MLX5E_PFC_PREVEN_TOUT_MIN_MSEC)) {
+   netdev_info(netdev, "%s: pfc prevention tout not in range 
(%d-%d)\n",
+   __func__, MLX5E_PFC_PREVEN_TOUT_MIN_MSEC,
+   MLX5E_PFC_PREVEN_TOUT_MAX_MSEC);
+   return -EINVAL;
+   }
+
+   minor = MLX5E_DEVICE_STALL_MINOR_WATERMARK(critical_tout);
+   return mlx5_set_port_stall_watermark(mdev, critical_tout,
+minor);
+}
+
 static int mlx5e_get_tunable(struct net_device *dev,
 const struct ethtool_tunable *tuna,
 void *data)
@@ -1077,6 +1128,9 @@ static int mlx5e_get_tunable(struct net_device *dev,
case ETHTOOL_TX_COPYBREAK:
*(u32 *)data = priv->channels.params.tx_max_inline;
break;
+   case ETHTOOL_PFC_PREVENTION_TOUT:
+   err = mlx5e_get_pfc_prevention_tout(dev, data);
+   break;
default:
err = -EINVAL;
break;
@@ -1118,6 +1172,9 @@ static int mlx5e_set_tunable(struct net_device *dev,
break;
mlx5e_switch_priv_channels(priv, _channels, NULL);
 
+   break;
+   case ETHTOOL_PFC_PREVENTION_TOUT:
+   err = mlx5e_set_pfc_prevention_tout(dev, *(u16 *)data);
break;
default:
err = -EINVAL;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/port.c 
b/drivers/net/ethernet/mellanox/mlx5/core/port.c
index c37d00cd472a..fa9d0760dd36 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/port.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/port.c
@@ -483,6 +483,17 @@ int mlx5_core_query_ib_ppcnt(struct mlx5_core_dev *dev,
 }
 EXPORT_SYMBOL_GPL(mlx5_core_query_ib_ppcnt);
 
+static int mlx5_query_pfcc_reg(struct mlx5_core_dev *dev, u32 *out,
+  u32 out_size)
+{
+   u32 in[MLX5_ST_SZ_DW(pfcc_reg)] = {0};
+
+   MLX5_SET(pfcc_reg, in, local_port, 1);
+
+   return mlx5_core_access_reg(dev, in, sizeof(in), out,
+   out_size, MLX5_REG_PFCC, 0, 0);
+}
+
 int mlx5_set_port_pause(struct 

[net-next 11/15] net/mlx5: Protect from command bit overflow

2018-03-23 Thread Saeed Mahameed
From: Leon Romanovsky 

The system with CONFIG_UBSAN enabled on produces the following error
during driver initialization. The reason to it that max_reg_cmds can be
larger enough to cause to "1 << max_reg_cmds" overflow the unsigned long.


UBSAN: Undefined behaviour in 
drivers/net/ethernet/mellanox/mlx5/core/cmd.c:1805:42
signed integer overflow:
-2147483648 - 1 cannot be represented in type 'int'
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.15.0-rc2-00032-g06cda2358d9b-dirty 
#724
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
rel-1.7.5-0-ge51488c-20140602_164612-nilsson.home.kraxel.org 04/01/2014
Call Trace:
 dump_stack+0xe9/0x18f
 ? dma_virt_alloc+0x81/0x81
 ubsan_epilogue+0xe/0x4e
 handle_overflow+0x187/0x20c
 mlx5_cmd_init+0x73a/0x12b0
 mlx5_load_one+0x1c3d/0x1d30
 init_one+0xd02/0xf10
 pci_device_probe+0x26c/0x3b0
 driver_probe_device+0x622/0xb40
 __driver_attach+0x175/0x1b0
 bus_for_each_dev+0xef/0x190
 bus_add_driver+0x2db/0x490
 driver_register+0x16b/0x1e0
 __pci_register_driver+0x177/0x1b0
 init+0x6d/0x92
 do_one_initcall+0x15b/0x270
 kernel_init_freeable+0x2d8/0x3d0
 kernel_init+0x14/0x190
 ret_from_fork+0x24/0x30


Signed-off-by: Leon Romanovsky 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c 
b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index fe5428667ad1..21cd1703a862 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -1804,7 +1804,7 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)
 
cmd->checksum_disabled = 1;
cmd->max_reg_cmds = (1 << cmd->log_sz) - 1;
-   cmd->bitmask = (1 << cmd->max_reg_cmds) - 1;
+   cmd->bitmask = (1UL << cmd->max_reg_cmds) - 1;
 
cmd->cmdif_rev = ioread32be(>iseg->cmdif_rev_fw_sub) >> 16;
if (cmd->cmdif_rev > CMD_IF_REV) {
-- 
2.14.3



[net-next 06/15] net/mlx5: Add packet dropped while vport down statistics

2018-03-23 Thread Saeed Mahameed
From: Moshe Shemesh 

Added the following packets dropped while vport down statistics:

Rx dropped while vport down - counts packets which were steered by
e-switch to a vport, but dropped since the vport was down. This counter
will be shown on ip link tool as part of the vport rx_dropped counter.

Tx dropped while vport down - counts packets which were transmitted by
a vport, but dropped due to vport logical link down. This counter
will be shown on ip link tool as part of the vport tx_dropped counter.

The counters are read from FW by command QUERY_VNIC_ENV.

Signed-off-by: Moshe Shemesh 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 31 +++
 drivers/net/ethernet/mellanox/mlx5/core/vport.c   | 26 +++
 include/linux/mlx5/mlx5_ifc.h |  4 ++-
 include/linux/mlx5/vport.h|  3 +++
 4 files changed, 58 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c 
b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index 77b7272eaaa8..332bc56306bf 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -2096,17 +2096,19 @@ int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch 
*esw, int vport,
return err;
 }
 
-static void mlx5_eswitch_query_vport_drop_stats(struct mlx5_core_dev *dev,
-   int vport_idx,
-   struct mlx5_vport_drop_stats 
*stats)
+static int mlx5_eswitch_query_vport_drop_stats(struct mlx5_core_dev *dev,
+  int vport_idx,
+  struct mlx5_vport_drop_stats 
*stats)
 {
struct mlx5_eswitch *esw = dev->priv.eswitch;
struct mlx5_vport *vport = >vports[vport_idx];
+   u64 rx_discard_vport_down, tx_discard_vport_down;
u64 bytes = 0;
u16 idx = 0;
+   int err = 0;
 
if (!vport->enabled || esw->mode != SRIOV_LEGACY)
-   return;
+   return 0;
 
if (vport->egress.drop_counter) {
idx = vport->egress.drop_counter->id;
@@ -2117,6 +2119,23 @@ static void mlx5_eswitch_query_vport_drop_stats(struct 
mlx5_core_dev *dev,
idx = vport->ingress.drop_counter->id;
mlx5_fc_query(dev, idx, >tx_dropped, );
}
+
+   if (!MLX5_CAP_GEN(dev, receive_discard_vport_down) &&
+   !MLX5_CAP_GEN(dev, transmit_discard_vport_down))
+   return 0;
+
+   err = mlx5_query_vport_down_stats(dev, vport_idx,
+ _discard_vport_down,
+ _discard_vport_down);
+   if (err)
+   return err;
+
+   if (MLX5_CAP_GEN(dev, receive_discard_vport_down))
+   stats->rx_dropped += rx_discard_vport_down;
+   if (MLX5_CAP_GEN(dev, transmit_discard_vport_down))
+   stats->tx_dropped += tx_discard_vport_down;
+
+   return 0;
 }
 
 int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw,
@@ -2180,7 +2199,9 @@ int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw,
vf_stats->broadcast =
MLX5_GET_CTR(out, received_eth_broadcast.packets);
 
-   mlx5_eswitch_query_vport_drop_stats(esw->dev, vport, );
+   err = mlx5_eswitch_query_vport_drop_stats(esw->dev, vport, );
+   if (err)
+   goto free_out;
vf_stats->rx_dropped = stats.rx_dropped;
vf_stats->tx_dropped = stats.tx_dropped;
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vport.c 
b/drivers/net/ethernet/mellanox/mlx5/core/vport.c
index dfe36cf6fbea..177e076b8d17 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/vport.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/vport.c
@@ -1070,6 +1070,32 @@ int mlx5_core_query_vport_counter(struct mlx5_core_dev 
*dev, u8 other_vport,
 }
 EXPORT_SYMBOL_GPL(mlx5_core_query_vport_counter);
 
+int mlx5_query_vport_down_stats(struct mlx5_core_dev *mdev, u16 vport,
+   u64 *rx_discard_vport_down,
+   u64 *tx_discard_vport_down)
+{
+   u32 out[MLX5_ST_SZ_DW(query_vnic_env_out)] = {0};
+   u32 in[MLX5_ST_SZ_DW(query_vnic_env_in)] = {0};
+   int err;
+
+   MLX5_SET(query_vnic_env_in, in, opcode,
+MLX5_CMD_OP_QUERY_VNIC_ENV);
+   MLX5_SET(query_vnic_env_in, in, op_mod, 0);
+   MLX5_SET(query_vnic_env_in, in, vport_number, vport);
+   if (vport)
+   MLX5_SET(query_vnic_env_in, in, other_vport, 1);
+
+   err = mlx5_cmd_exec(mdev, in, sizeof(in), out, sizeof(out));
+   if (err)
+   return err;
+
+   *rx_discard_vport_down = MLX5_GET64(query_vnic_env_out, out,
+   
vport_env.receive_discard_vport_down);
+  

[net-next 10/15] net/mlx5e: Offload tc vlan push/pop using HW action

2018-03-23 Thread Saeed Mahameed
From: Or Gerlitz 

Currently, we are emulating the offload of vlan push/pop actions using
global setup as done by commit f5f82476090f ("net/mlx5: E-Switch, Support
VLAN actions in the offloads mode"). With newer NICs, we can apply a flow
action for that matter, do that while keeping the emulated path for the
older HW brands.

Signed-off-by: Or Gerlitz 
Reviewed-by: Mark Bloch 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c| 15 -
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.h  | 10 -
 .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 26 +-
 3 files changed, 40 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 7c33df2034f0..3e4a7e81b67f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -2530,12 +2530,17 @@ static int parse_tc_fdb_actions(struct mlx5e_priv 
*priv, struct tcf_exts *exts,
if (tcf_vlan_action(a) == TCA_VLAN_ACT_POP) {
attr->action |= 
MLX5_FLOW_CONTEXT_ACTION_VLAN_POP;
} else if (tcf_vlan_action(a) == TCA_VLAN_ACT_PUSH) {
-   if (tcf_vlan_push_proto(a) != 
htons(ETH_P_8021Q) ||
-   tcf_vlan_push_prio(a))
-   return -EOPNOTSUPP;
-
attr->action |= 
MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH;
-   attr->vlan = tcf_vlan_push_vid(a);
+   attr->vlan_vid = tcf_vlan_push_vid(a);
+   if 
(mlx5_eswitch_vlan_actions_supported(priv->mdev)) {
+   attr->vlan_prio = tcf_vlan_push_prio(a);
+   attr->vlan_proto = 
tcf_vlan_push_proto(a);
+   if (!attr->vlan_proto)
+   attr->vlan_proto = 
htons(ETH_P_8021Q);
+   } else if (tcf_vlan_push_proto(a) != 
htons(ETH_P_8021Q) ||
+  tcf_vlan_push_prio(a)) {
+   return -EOPNOTSUPP;
+   }
} else { /* action is TCA_VLAN_ACT_MODIFY */
return -EOPNOTSUPP;
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h 
b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
index a435eb7971c6..4cd773fa55e3 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -232,7 +232,9 @@ struct mlx5_esw_flow_attr {
struct mlx5_eswitch_rep *out_rep;
 
int action;
-   u16 vlan;
+   __be16  vlan_proto;
+   u16 vlan_vid;
+   u8  vlan_prio;
boolvlan_handled;
u32 encap_id;
u32 mod_hdr_id;
@@ -255,6 +257,12 @@ int mlx5_eswitch_del_vlan_action(struct mlx5_eswitch *esw,
 int __mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
  int vport, u16 vlan, u8 qos, u8 set_flags);
 
+static inline bool mlx5_eswitch_vlan_actions_supported(struct mlx5_core_dev 
*dev)
+{
+   return MLX5_CAP_ESW_FLOWTABLE_FDB(dev, pop_vlan) &&
+  MLX5_CAP_ESW_FLOWTABLE_FDB(dev, push_vlan);
+}
+
 #define MLX5_DEBUG_ESWITCH_MASK BIT(3)
 
 #define esw_info(dev, format, ...) \
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c 
b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 21ebe3e80e6e..35e256eb2f6e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -58,8 +58,16 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
if (esw->mode != SRIOV_OFFLOADS)
return ERR_PTR(-EOPNOTSUPP);
 
-   /* per flow vlan pop/push is emulated, don't set that into the firmware 
*/
-   flow_act.action = attr->action & ~(MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH | 
MLX5_FLOW_CONTEXT_ACTION_VLAN_POP);
+   flow_act.action = attr->action;
+   /* if per flow vlan pop/push is emulated, don't set that into the 
firmware */
+   if (!mlx5_eswitch_vlan_actions_supported(esw->dev))
+   flow_act.action &= ~(MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH |
+MLX5_FLOW_CONTEXT_ACTION_VLAN_POP);
+   else if (flow_act.action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH) {
+   flow_act.vlan.ethtype = ntohs(attr->vlan_proto);
+   flow_act.vlan.vid = attr->vlan_vid;
+   flow_act.vlan.prio = attr->vlan_prio;
+   }
 
if 

[net-next 07/15] net/mlx5e: Add interface down dropped packets statistics

2018-03-23 Thread Saeed Mahameed
From: Moshe Shemesh 

Added the following packets drop counter:
Rx interface down dropped packets - counts packets which were received
while the ETH interface was down.
This counter will be shown on ethtool as a new counter called
rx_if_down_packets.

The implementation allocates a q_counter for drop rq which gets all the
received traffic while the interface is down.

Signed-off-by: Moshe Shemesh 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/en.h   |  3 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  | 46 +
 drivers/net/ethernet/mellanox/mlx5/core/en_stats.c | 48 --
 drivers/net/ethernet/mellanox/mlx5/core/en_stats.h |  1 +
 4 files changed, 69 insertions(+), 29 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h 
b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 4c9360b25532..48e0b2a747d9 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -781,7 +781,8 @@ struct mlx5e_priv {
struct net_device *netdev;
struct mlx5e_stats stats;
struct hwtstamp_config tstamp;
-   u16 q_counter;
+   u16q_counter;
+   u16drop_rq_q_counter;
 #ifdef CONFIG_MLX5_CORE_EN_DCB
struct mlx5e_dcbx  dcbx;
 #endif
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index da94c8cba5ee..f8bc3bcdf046 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -615,8 +615,7 @@ static int mlx5e_create_rq(struct mlx5e_rq *rq,
 static int mlx5e_modify_rq_state(struct mlx5e_rq *rq, int curr_state,
 int next_state)
 {
-   struct mlx5e_channel *c = rq->channel;
-   struct mlx5_core_dev *mdev = c->mdev;
+   struct mlx5_core_dev *mdev = rq->mdev;
 
void *in;
void *rqc;
@@ -1768,14 +1767,16 @@ static void mlx5e_build_rq_param(struct mlx5e_priv 
*priv,
param->wq.linear = 1;
 }
 
-static void mlx5e_build_drop_rq_param(struct mlx5_core_dev *mdev,
+static void mlx5e_build_drop_rq_param(struct mlx5e_priv *priv,
  struct mlx5e_rq_param *param)
 {
+   struct mlx5_core_dev *mdev = priv->mdev;
void *rqc = param->rqc;
void *wq = MLX5_ADDR_OF(rqc, rqc, wq);
 
MLX5_SET(wq, wq, wq_type, MLX5_WQ_TYPE_LINKED_LIST);
MLX5_SET(wq, wq, log_wq_stride,ilog2(sizeof(struct mlx5e_rx_wqe)));
+   MLX5_SET(rqc, rqc, counter_set_id, priv->drop_rq_q_counter);
 
param->wq.buf_numa_node = dev_to_node(>pdev->dev);
 }
@@ -2643,15 +2644,16 @@ static int mlx5e_alloc_drop_cq(struct mlx5_core_dev 
*mdev,
return mlx5e_alloc_cq_common(mdev, param, cq);
 }
 
-static int mlx5e_open_drop_rq(struct mlx5_core_dev *mdev,
+static int mlx5e_open_drop_rq(struct mlx5e_priv *priv,
  struct mlx5e_rq *drop_rq)
 {
+   struct mlx5_core_dev *mdev = priv->mdev;
struct mlx5e_cq_param cq_param = {};
struct mlx5e_rq_param rq_param = {};
struct mlx5e_cq *cq = _rq->cq;
int err;
 
-   mlx5e_build_drop_rq_param(mdev, _param);
+   mlx5e_build_drop_rq_param(priv, _param);
 
err = mlx5e_alloc_drop_cq(mdev, cq, _param);
if (err)
@@ -2669,6 +2671,10 @@ static int mlx5e_open_drop_rq(struct mlx5_core_dev *mdev,
if (err)
goto err_free_rq;
 
+   err = mlx5e_modify_rq_state(drop_rq, MLX5_RQC_STATE_RST, 
MLX5_RQC_STATE_RDY);
+   if (err)
+   mlx5_core_warn(priv->mdev, "modify_rq_state failed, 
rx_if_down_packets won't be counted %d\n", err);
+
return 0;
 
 err_free_rq:
@@ -4183,7 +4189,7 @@ static void mlx5e_build_nic_netdev(struct net_device 
*netdev)
mlx5e_ipsec_build_netdev(priv);
 }
 
-static void mlx5e_create_q_counter(struct mlx5e_priv *priv)
+static void mlx5e_create_q_counters(struct mlx5e_priv *priv)
 {
struct mlx5_core_dev *mdev = priv->mdev;
int err;
@@ -4193,14 +4199,21 @@ static void mlx5e_create_q_counter(struct mlx5e_priv 
*priv)
mlx5_core_warn(mdev, "alloc queue counter failed, %d\n", err);
priv->q_counter = 0;
}
+
+   err = mlx5_core_alloc_q_counter(mdev, >drop_rq_q_counter);
+   if (err) {
+   mlx5_core_warn(mdev, "alloc drop RQ counter failed, %d\n", err);
+   priv->drop_rq_q_counter = 0;
+   }
 }
 
-static void mlx5e_destroy_q_counter(struct mlx5e_priv *priv)
+static void mlx5e_destroy_q_counters(struct mlx5e_priv *priv)
 {
-   if (!priv->q_counter)
-   return;
+   if (priv->q_counter)
+   mlx5_core_dealloc_q_counter(priv->mdev, priv->q_counter);
 
-   mlx5_core_dealloc_q_counter(priv->mdev, 

[net-next 14/15] net/mlx5e: Add a helper macro in set features ndo

2018-03-23 Thread Saeed Mahameed
From: Gal Pressman 

Add a new macro to prevent copy-pasting the same code for each new
feature.

Signed-off-by: Gal Pressman 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 26 ++-
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index eb38a35564c7..fb936a978f20 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -3242,24 +3242,20 @@ static int mlx5e_set_features(struct net_device *netdev,
  netdev_features_t features)
 {
netdev_features_t oper_features = netdev->features;
-   int err;
+   int err = 0;
+
+#define MLX5E_HANDLE_FEATURE(feature, handler) \
+   mlx5e_handle_feature(netdev, _features, features, feature, handler)
 
-   err  = mlx5e_handle_feature(netdev, _features, features,
-   NETIF_F_LRO, set_feature_lro);
-   err |= mlx5e_handle_feature(netdev, _features, features,
-   NETIF_F_HW_VLAN_CTAG_FILTER,
+   err |= MLX5E_HANDLE_FEATURE(NETIF_F_LRO, set_feature_lro);
+   err |= MLX5E_HANDLE_FEATURE(NETIF_F_HW_VLAN_CTAG_FILTER,
set_feature_cvlan_filter);
-   err |= mlx5e_handle_feature(netdev, _features, features,
-   NETIF_F_HW_TC, set_feature_tc_num_filters);
-   err |= mlx5e_handle_feature(netdev, _features, features,
-   NETIF_F_RXALL, set_feature_rx_all);
-   err |= mlx5e_handle_feature(netdev, _features, features,
-   NETIF_F_RXFCS, set_feature_rx_fcs);
-   err |= mlx5e_handle_feature(netdev, _features, features,
-   NETIF_F_HW_VLAN_CTAG_RX, 
set_feature_rx_vlan);
+   err |= MLX5E_HANDLE_FEATURE(NETIF_F_HW_TC, set_feature_tc_num_filters);
+   err |= MLX5E_HANDLE_FEATURE(NETIF_F_RXALL, set_feature_rx_all);
+   err |= MLX5E_HANDLE_FEATURE(NETIF_F_RXFCS, set_feature_rx_fcs);
+   err |= MLX5E_HANDLE_FEATURE(NETIF_F_HW_VLAN_CTAG_RX, 
set_feature_rx_vlan);
 #ifdef CONFIG_RFS_ACCEL
-   err |= mlx5e_handle_feature(netdev, _features, features,
-   NETIF_F_NTUPLE, set_feature_arfs);
+   err |= MLX5E_HANDLE_FEATURE(NETIF_F_NTUPLE, set_feature_arfs);
 #endif
 
if (err) {
-- 
2.14.3



[net-next 04/15] net/mlx5: Add support for QUERY_VNIC_ENV command

2018-03-23 Thread Saeed Mahameed
From: Moshe Shemesh 

Add support for new FW command QUERY_VNIC_ENV.
The command is used by the driver to query vnic diagnostic statistics
from FW.

Signed-off-by: Moshe Shemesh 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c |  2 ++
 include/linux/mlx5/mlx5_ifc.h | 50 ++-
 2 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c 
b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index e9a1fbcc4adf..fe5428667ad1 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -359,6 +359,7 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev 
*dev, u16 op,
case MLX5_CMD_OP_MODIFY_HCA_VPORT_CONTEXT:
case MLX5_CMD_OP_QUERY_HCA_VPORT_GID:
case MLX5_CMD_OP_QUERY_HCA_VPORT_PKEY:
+   case MLX5_CMD_OP_QUERY_VNIC_ENV:
case MLX5_CMD_OP_QUERY_VPORT_COUNTER:
case MLX5_CMD_OP_ALLOC_Q_COUNTER:
case MLX5_CMD_OP_QUERY_Q_COUNTER:
@@ -501,6 +502,7 @@ const char *mlx5_command_str(int command)
MLX5_COMMAND_STR_CASE(MODIFY_HCA_VPORT_CONTEXT);
MLX5_COMMAND_STR_CASE(QUERY_HCA_VPORT_GID);
MLX5_COMMAND_STR_CASE(QUERY_HCA_VPORT_PKEY);
+   MLX5_COMMAND_STR_CASE(QUERY_VNIC_ENV);
MLX5_COMMAND_STR_CASE(QUERY_VPORT_COUNTER);
MLX5_COMMAND_STR_CASE(ALLOC_Q_COUNTER);
MLX5_COMMAND_STR_CASE(DEALLOC_Q_COUNTER);
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index f3200a9696d6..52e373dd2679 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -143,6 +143,7 @@ enum {
MLX5_CMD_OP_MODIFY_HCA_VPORT_CONTEXT  = 0x763,
MLX5_CMD_OP_QUERY_HCA_VPORT_GID   = 0x764,
MLX5_CMD_OP_QUERY_HCA_VPORT_PKEY  = 0x765,
+   MLX5_CMD_OP_QUERY_VNIC_ENV= 0x76f,
MLX5_CMD_OP_QUERY_VPORT_COUNTER   = 0x770,
MLX5_CMD_OP_ALLOC_Q_COUNTER   = 0x771,
MLX5_CMD_OP_DEALLOC_Q_COUNTER = 0x772,
@@ -875,7 +876,7 @@ struct mlx5_ifc_cmd_hca_cap_bits {
u8 vhca_group_manager[0x1];
u8 ib_virt[0x1];
u8 eth_virt[0x1];
-   u8 reserved_at_1a4[0x1];
+   u8 vnic_env_queue_counters[0x1];
u8 ets[0x1];
u8 nic_flow_table[0x1];
u8 eswitch_flow_table[0x1];
@@ -2386,6 +2387,24 @@ struct mlx5_ifc_xrc_srqc_bits {
u8 reserved_at_180[0x80];
 };
 
+struct mlx5_ifc_vnic_diagnostic_statistics_bits {
+   u8 counter_error_queues[0x20];
+
+   u8 total_error_queues[0x20];
+
+   u8 send_queue_priority_update_flow[0x20];
+
+   u8 reserved_at_60[0x20];
+
+   u8 nic_receive_steering_discard[0x40];
+
+   u8 receive_discard_vport_down[0x40];
+
+   u8 transmit_discard_vport_down[0x40];
+
+   u8 reserved_at_140[0xec0];
+};
+
 struct mlx5_ifc_traffic_counter_bits {
u8 packets[0x40];
 
@@ -3661,6 +3680,35 @@ struct mlx5_ifc_query_vport_state_in_bits {
u8 reserved_at_60[0x20];
 };
 
+struct mlx5_ifc_query_vnic_env_out_bits {
+   u8 status[0x8];
+   u8 reserved_at_8[0x18];
+
+   u8 syndrome[0x20];
+
+   u8 reserved_at_40[0x40];
+
+   struct mlx5_ifc_vnic_diagnostic_statistics_bits vport_env;
+};
+
+enum {
+   MLX5_QUERY_VNIC_ENV_IN_OP_MOD_VPORT_DIAG_STATISTICS  = 0x0,
+};
+
+struct mlx5_ifc_query_vnic_env_in_bits {
+   u8 opcode[0x10];
+   u8 reserved_at_10[0x10];
+
+   u8 reserved_at_20[0x10];
+   u8 op_mod[0x10];
+
+   u8 other_vport[0x1];
+   u8 reserved_at_41[0xf];
+   u8 vport_number[0x10];
+
+   u8 reserved_at_60[0x20];
+};
+
 struct mlx5_ifc_query_vport_counter_out_bits {
u8 status[0x8];
u8 reserved_at_8[0x18];
-- 
2.14.3



[net-next 08/15] net/mlx5: E-Switch, Use same source for offloaded actions check

2018-03-23 Thread Saeed Mahameed
From: Or Gerlitz 

Align the checks for modify header and encap actions with the
rest of the code.

Signed-off-by: Or Gerlitz 
Reviewed-by: Mark Bloch 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c 
b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 0a8303c1b52f..21ebe3e80e6e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -88,10 +88,10 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
if (flow_act.action & MLX5_FLOW_CONTEXT_ACTION_DECAP)
spec->match_criteria_enable |= MLX5_MATCH_INNER_HEADERS;
 
-   if (attr->action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)
+   if (flow_act.action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)
flow_act.modify_id = attr->mod_hdr_id;
 
-   if (attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP)
+   if (flow_act.action & MLX5_FLOW_CONTEXT_ACTION_ENCAP)
flow_act.encap_id = attr->encap_id;
 
rule = mlx5_add_flow_rules((struct mlx5_flow_table *)esw->fdb_table.fdb,
-- 
2.14.3



[net-next 13/15] net/mlx5e: Make choose LRO timeout function static

2018-03-23 Thread Saeed Mahameed
From: Gal Pressman 

The function is used in en_main.c only, we can make it static and remove
its declaration from en.h

Signed-off-by: Gal Pressman 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/en.h  | 1 -
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h 
b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 48e0b2a747d9..294bc9f175a5 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -1062,7 +1062,6 @@ void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv);
 int mlx5e_close(struct net_device *netdev);
 int mlx5e_open(struct net_device *netdev);
 void mlx5e_update_stats_work(struct work_struct *work);
-u32 mlx5e_choose_lro_timeout(struct mlx5_core_dev *mdev, u32 wanted_timeout);
 
 int mlx5e_bits_invert(unsigned long a, int size);
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index f8bc3bcdf046..eb38a35564c7 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -3967,7 +3967,7 @@ void mlx5e_set_rx_cq_mode_params(struct mlx5e_params 
*params, u8 cq_period_mode)
MLX5_CQ_PERIOD_MODE_START_FROM_CQE);
 }
 
-u32 mlx5e_choose_lro_timeout(struct mlx5_core_dev *mdev, u32 wanted_timeout)
+static u32 mlx5e_choose_lro_timeout(struct mlx5_core_dev *mdev, u32 
wanted_timeout)
 {
int i;
 
-- 
2.14.3



[net-next 01/15] net/mlx5e: Expose PFC stall prevention counters

2018-03-23 Thread Saeed Mahameed
From: Inbar Karmy 

Add the needed capability bit and counters to device spec description.
Expose the following two counters in ethtool:

tx_pause_storm_warning_events: when the device is stalled for a period
longer than a pre-configured watermark, the counter increase, allowing
the debug utility an insight into current device status.

tx_pause_storm_error_events: when the device is stalled for a period
longer than a pre-configured timeout, the pause transmission is disabled,
and the counter increase.

Signed-off-by: Inbar Karmy 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_stats.c | 19 ++-
 drivers/net/ethernet/mellanox/mlx5/core/fw.c   |  3 +++
 include/linux/mlx5/device.h|  4 
 include/linux/mlx5/mlx5_ifc.h  | 28 +++---
 4 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
index 5f0f3493d747..2553c58dcf1c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
@@ -754,7 +754,15 @@ static const struct counter_desc 
pport_per_prio_pfc_stats_desc[] = {
{ "rx_%s_pause_transition", PPORT_PER_PRIO_OFF(rx_pause_transition) },
 };
 
+static const struct counter_desc pport_pfc_stall_stats_desc[] = {
+   { "tx_pause_storm_warning_events ", 
PPORT_PER_PRIO_OFF(device_stall_minor_watermark_cnt) },
+   { "tx_pause_storm_error_events", 
PPORT_PER_PRIO_OFF(device_stall_critical_watermark_cnt) },
+};
+
 #define NUM_PPORT_PER_PRIO_PFC_COUNTERS
ARRAY_SIZE(pport_per_prio_pfc_stats_desc)
+#define NUM_PPORT_PFC_STALL_COUNTERS(priv) 
(ARRAY_SIZE(pport_pfc_stall_stats_desc) * \
+
MLX5_CAP_PCAM_FEATURE((priv)->mdev, pfcc_mask) * \
+MLX5_CAP_DEBUG((priv)->mdev, 
stall_detect))
 
 static unsigned long mlx5e_query_pfc_combined(struct mlx5e_priv *priv)
 {
@@ -790,7 +798,8 @@ static int mlx5e_grp_per_prio_pfc_get_num_stats(struct 
mlx5e_priv *priv)
 {
return (mlx5e_query_global_pause_combined(priv) +
hweight8(mlx5e_query_pfc_combined(priv))) *
-   NUM_PPORT_PER_PRIO_PFC_COUNTERS;
+   NUM_PPORT_PER_PRIO_PFC_COUNTERS +
+   NUM_PPORT_PFC_STALL_COUNTERS(priv);
 }
 
 static int mlx5e_grp_per_prio_pfc_fill_strings(struct mlx5e_priv *priv,
@@ -818,6 +827,10 @@ static int mlx5e_grp_per_prio_pfc_fill_strings(struct 
mlx5e_priv *priv,
}
}
 
+   for (i = 0; i < NUM_PPORT_PFC_STALL_COUNTERS(priv); i++)
+   strcpy(data + (idx++) * ETH_GSTRING_LEN,
+  pport_pfc_stall_stats_desc[i].format);
+
return idx;
 }
 
@@ -845,6 +858,10 @@ static int mlx5e_grp_per_prio_pfc_fill_stats(struct 
mlx5e_priv *priv,
}
}
 
+   for (i = 0; i < NUM_PPORT_PFC_STALL_COUNTERS(priv); i++)
+   data[idx++] = 
MLX5E_READ_CTR64_BE(>stats.pport.per_prio_counters[0],
+ pport_pfc_stall_stats_desc, 
i);
+
return idx;
 }
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw.c 
b/drivers/net/ethernet/mellanox/mlx5/core/fw.c
index 9d11e92fb541..d7bb10ab2173 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fw.c
@@ -183,6 +183,9 @@ int mlx5_query_hca_caps(struct mlx5_core_dev *dev)
return err;
}
 
+   if (MLX5_CAP_GEN(dev, debug))
+   mlx5_core_get_caps(dev, MLX5_CAP_DEBUG);
+
if (MLX5_CAP_GEN(dev, pcam_reg))
mlx5_get_pcam_reg(dev);
 
diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h
index e5258ee4e38b..4b5939c78cdd 100644
--- a/include/linux/mlx5/device.h
+++ b/include/linux/mlx5/device.h
@@ -1013,6 +1013,7 @@ enum mlx5_cap_type {
MLX5_CAP_RESERVED,
MLX5_CAP_VECTOR_CALC,
MLX5_CAP_QOS,
+   MLX5_CAP_DEBUG,
/* NUM OF CAP Types */
MLX5_CAP_NUM
 };
@@ -1140,6 +1141,9 @@ enum mlx5_qcam_feature_groups {
 #define MLX5_CAP_QOS(mdev, cap)\
MLX5_GET(qos_cap, mdev->caps.hca_cur[MLX5_CAP_QOS], cap)
 
+#define MLX5_CAP_DEBUG(mdev, cap)\
+   MLX5_GET(debug_cap, mdev->caps.hca_cur[MLX5_CAP_DEBUG], cap)
+
 #define MLX5_CAP_PCAM_FEATURE(mdev, fld) \
MLX5_GET(pcam_reg, (mdev)->caps.pcam, 
feature_cap_mask.enhanced_features.fld)
 
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 14ad84afe8ba..c7d50eccff9e 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -593,6 +593,16 @@ struct mlx5_ifc_qos_cap_bits {
u8 reserved_at_100[0x700];
 };
 
+struct mlx5_ifc_debug_cap_bits {
+   u8 reserved_at_0[0x20];
+

[net-next 12/15] net/mlx5e: Remove redundant check in get ethtool stats

2018-03-23 Thread Saeed Mahameed
From: Gal Pressman 

ethtool core code makes sure data isn't NULL before calling
get_ethtool_stats, testing it again in the driver is redundant.

Signed-off-by: Gal Pressman 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index 62061fd23143..d415e67b557b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -203,9 +203,6 @@ void mlx5e_ethtool_get_ethtool_stats(struct mlx5e_priv 
*priv,
 {
int i, idx = 0;
 
-   if (!data)
-   return;
-
mutex_lock(>state_lock);
mlx5e_update_stats(priv);
mutex_unlock(>state_lock);
-- 
2.14.3



[net-next 09/15] net/mlx5: Add core support for vlan push/pop steering action

2018-03-23 Thread Saeed Mahameed
From: Or Gerlitz 

Newer NICs (ConnectX-5 and onward) can apply vlan pop or push as an
action taking place during flow steering. Add the core bits for that.

Signed-off-by: Or Gerlitz 
Reviewed-by: Mark Bloch 
Signed-off-by: Saeed Mahameed 
---
 .../net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.h |  2 ++
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.h|  3 ---
 drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 10 +-
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.c|  4 +++-
 include/linux/mlx5/fs.h  |  7 +++
 include/linux/mlx5/mlx5_ifc.h| 16 ++--
 6 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.h 
b/drivers/net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.h
index a6ba57fbb414..09f178a3fcab 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.h
@@ -136,6 +136,8 @@ TRACE_EVENT(mlx5_fs_del_fg,
{MLX5_FLOW_CONTEXT_ACTION_ENCAP, "ENCAP"},\
{MLX5_FLOW_CONTEXT_ACTION_DECAP, "DECAP"},\
{MLX5_FLOW_CONTEXT_ACTION_MOD_HDR,   "MOD_HDR"},\
+   {MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH, "VLAN_PUSH"},\
+   {MLX5_FLOW_CONTEXT_ACTION_VLAN_POP,  "VLAN_POP"},\
{MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO, "NEXT_PRIO"}
 
 TRACE_EVENT(mlx5_fs_set_fte,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h 
b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
index 98d2177d0806..a435eb7971c6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -227,9 +227,6 @@ enum {
SET_VLAN_INSERT = BIT(1)
 };
 
-#define MLX5_FLOW_CONTEXT_ACTION_VLAN_POP  0x4000
-#define MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH 0x8000
-
 struct mlx5_esw_flow_attr {
struct mlx5_eswitch_rep *in_rep;
struct mlx5_eswitch_rep *out_rep;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c 
b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
index 645f83cac34d..ef5afd7c9325 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
@@ -317,7 +317,7 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
fte->dests_size * MLX5_ST_SZ_BYTES(dest_format_struct);
u32 out[MLX5_ST_SZ_DW(set_fte_out)] = {0};
struct mlx5_flow_rule *dst;
-   void *in_flow_context;
+   void *in_flow_context, *vlan;
void *in_match_value;
void *in_dests;
u32 *in;
@@ -340,11 +340,19 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
 
in_flow_context = MLX5_ADDR_OF(set_fte_in, in, flow_context);
MLX5_SET(flow_context, in_flow_context, group_id, group_id);
+
MLX5_SET(flow_context, in_flow_context, flow_tag, fte->action.flow_tag);
MLX5_SET(flow_context, in_flow_context, action, fte->action.action);
MLX5_SET(flow_context, in_flow_context, encap_id, fte->action.encap_id);
MLX5_SET(flow_context, in_flow_context, modify_header_id,
 fte->action.modify_id);
+
+   vlan = MLX5_ADDR_OF(flow_context, in_flow_context, push_vlan);
+
+   MLX5_SET(vlan, vlan, ethtype, fte->action.vlan.ethtype);
+   MLX5_SET(vlan, vlan, vid, fte->action.vlan.vid);
+   MLX5_SET(vlan, vlan, prio, fte->action.vlan.prio);
+
in_match_value = MLX5_ADDR_OF(flow_context, in_flow_context,
  match_value);
memcpy(in_match_value, >val, sizeof(fte->val));
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c 
b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index 3ba07c7096ef..de51e7c39bc8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -1439,7 +1439,9 @@ static bool check_conflicting_actions(u32 action1, u32 
action2)
if (xored_actions & (MLX5_FLOW_CONTEXT_ACTION_DROP  |
 MLX5_FLOW_CONTEXT_ACTION_ENCAP |
 MLX5_FLOW_CONTEXT_ACTION_DECAP |
-MLX5_FLOW_CONTEXT_ACTION_MOD_HDR))
+MLX5_FLOW_CONTEXT_ACTION_MOD_HDR  |
+MLX5_FLOW_CONTEXT_ACTION_VLAN_POP |
+MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH))
return true;
 
return false;
diff --git a/include/linux/mlx5/fs.h b/include/linux/mlx5/fs.h
index b957e52434f8..47aecc4fa8c2 100644
--- a/include/linux/mlx5/fs.h
+++ b/include/linux/mlx5/fs.h
@@ -142,6 +142,12 @@ struct mlx5_flow_group *
 mlx5_create_flow_group(struct mlx5_flow_table *ft, u32 *in);
 void mlx5_destroy_flow_group(struct mlx5_flow_group *fg);
 
+struct mlx5_fs_vlan {
+u16 ethtype;
+ 

[pull request][net-next 00/15] Mellanox, mlx5 misc updates 2018-03-22

2018-03-23 Thread Saeed Mahameed
Hi Dave,

This series includes some misc updates to mlx5 core and netdev driver,
please note that there is a small change to net/core/ethtool.c and 
include/uapi/linux/ethtool.h that adds new tunable for PFC stall
prevention on/off support, which was already reviewed as RFC [1].

For more information please review and see the tag log below.

Please pull and let me know if there's any problem.

P.S.: This series doesn't introduce any conflict with the ongoing
mlx5 fixes series, mlx5-fixes-2018-03-23.

[1] https://patchwork.ozlabs.org/cover/838314/

Thanks,
Saeed.

---

The following changes since commit 6686c459e1449a3ee5f3fd313b0a559ace7a700e:

  Merge branch 'hns3-VF-reset' (2018-03-22 15:29:05 -0400)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git 
tags/mlx5-updates-2018-03-22

for you to fetch changes up to 50f0e3bc5e4b5079b1e9b829db1a2246757965d3:

  net/mlx5e: Add VLAN offload features to hw_enc_features (2018-03-22 16:28:31 
-0700)


mlx5-updates-2018-03-22 (Misc updates)

This series includes misc updates for mlx5 core and netdev dirver,

Highlights:

>From Inbar, three patches to add support for PFC stall prevention
statistics and enable/disable through new ethtool tunable, as requested
from previous submission.

>From Moshe, four patches, added more drop counters:
- drop counter for netdev steering miss
- drop counter for when VF logical link is down
- drop counter for when netdev logical link is down.

>From Or, three patches to support vlan push/pop offload via tc HW action,
for newer HW (Connectx-5 and onward) via HW steering flow actions rather
than the emulated path for the older HW brands.

And five more misc small trivial patches.


Aviv Heller (1):
  net/mlx5e: Add VLAN offload features to hw_enc_features

Gal Pressman (3):
  net/mlx5e: Remove redundant check in get ethtool stats
  net/mlx5e: Make choose LRO timeout function static
  net/mlx5e: Add a helper macro in set features ndo

Inbar Karmy (3):
  net/mlx5e: Expose PFC stall prevention counters
  ethtool: Add support for configuring PFC stall prevention in ethtool
  net/mlx5e: PFC stall prevention support

Leon Romanovsky (1):
  net/mlx5: Protect from command bit overflow

Moshe Shemesh (4):
  net/mlx5: Add support for QUERY_VNIC_ENV command
  net/mlx5e: Add vnic steering drop statistics
  net/mlx5: Add packet dropped while vport down statistics
  net/mlx5e: Add interface down dropped packets statistics

Or Gerlitz (3):
  net/mlx5: E-Switch, Use same source for offloaded actions check
  net/mlx5: Add core support for vlan push/pop steering action
  net/mlx5e: Offload tc vlan push/pop using HW action

 drivers/net/ethernet/mellanox/mlx5/core/cmd.c  |   4 +-
 .../mellanox/mlx5/core/diag/fs_tracepoint.h|   2 +
 drivers/net/ethernet/mellanox/mlx5/core/en.h   |   4 +-
 .../net/ethernet/mellanox/mlx5/core/en_ethtool.c   |  60 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  |  77 +++--
 drivers/net/ethernet/mellanox/mlx5/core/en_stats.c | 126 +++--
 drivers/net/ethernet/mellanox/mlx5/core/en_stats.h |   6 +
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c|  15 ++-
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c  |  31 -
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.h  |  13 ++-
 .../ethernet/mellanox/mlx5/core/eswitch_offloads.c |  30 +++--
 drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c   |  10 +-
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.c  |   4 +-
 drivers/net/ethernet/mellanox/mlx5/core/fw.c   |   3 +
 drivers/net/ethernet/mellanox/mlx5/core/port.c |  64 +--
 drivers/net/ethernet/mellanox/mlx5/core/vport.c|  26 +
 include/linux/mlx5/device.h|   4 +
 include/linux/mlx5/fs.h|   7 ++
 include/linux/mlx5/mlx5_ifc.h  | 116 +--
 include/linux/mlx5/port.h  |   6 +
 include/linux/mlx5/vport.h |   3 +
 include/uapi/linux/ethtool.h   |   4 +
 net/core/ethtool.c |   6 +
 23 files changed, 531 insertions(+), 90 deletions(-)


[net-next 02/15] ethtool: Add support for configuring PFC stall prevention in ethtool

2018-03-23 Thread Saeed Mahameed
From: Inbar Karmy 

In the event where the device unexpectedly becomes unresponsive
for a long period of time, flow control mechanism may propagate
pause frames which will cause congestion spreading to the entire
network.
To prevent this scenario, when the device is stalled for a period
longer than a pre-configured timeout, flow control mechanisms are
automatically disabled.

This patch adds support for the ETHTOOL_PFC_STALL_PREVENTION
as a tunable.
This API provides support for configuring flow control storm prevention
timeout (msec).

Signed-off-by: Inbar Karmy 
Cc: Michal Kubecek 
Cc: Andrew Lunn 
Signed-off-by: Saeed Mahameed 
---
 include/uapi/linux/ethtool.h | 4 
 net/core/ethtool.c   | 6 ++
 2 files changed, 10 insertions(+)

diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index 20da156aaf64..9dc63a14a747 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -217,10 +217,14 @@ struct ethtool_value {
__u32   data;
 };
 
+#define PFC_STORM_PREVENTION_AUTO  0x
+#define PFC_STORM_PREVENTION_DISABLE   0
+
 enum tunable_id {
ETHTOOL_ID_UNSPEC,
ETHTOOL_RX_COPYBREAK,
ETHTOOL_TX_COPYBREAK,
+   ETHTOOL_PFC_PREVENTION_TOUT,
/*
 * Add your fresh new tubale attribute above and remember to update
 * tunable_strings[] in net/core/ethtool.c
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 157cd9efa4be..bb6e498c6e3d 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -121,6 +121,7 @@ tunable_strings[__ETHTOOL_TUNABLE_COUNT][ETH_GSTRING_LEN] = 
{
[ETHTOOL_ID_UNSPEC] = "Unspec",
[ETHTOOL_RX_COPYBREAK]  = "rx-copybreak",
[ETHTOOL_TX_COPYBREAK]  = "tx-copybreak",
+   [ETHTOOL_PFC_PREVENTION_TOUT] = "pfc-prevention-tout",
 };
 
 static const char
@@ -2311,6 +2312,11 @@ static int ethtool_tunable_valid(const struct 
ethtool_tunable *tuna)
tuna->type_id != ETHTOOL_TUNABLE_U32)
return -EINVAL;
break;
+   case ETHTOOL_PFC_PREVENTION_TOUT:
+   if (tuna->len != sizeof(u16) ||
+   tuna->type_id != ETHTOOL_TUNABLE_U16)
+   return -EINVAL;
+   break;
default:
return -EINVAL;
}
-- 
2.14.3



Re: [PATCH v6 6/6] bnxt_en: Eliminate duplicate barriers on weakly-ordered archs

2018-03-23 Thread Michael Chan
On Fri, Mar 23, 2018 at 3:23 PM, Sinan Kaya  wrote:
> Code includes wmb() followed by writel(). writel() already has a barrier on
> some architectures like arm64.
>
> This ends up CPU observing two barriers back to back before executing the
> register write.
>
> Create a new wrapper function with relaxed write operator. Use the new
> wrapper when a write is following a wmb().
>
> Since code already has an explicit barrier call, changing writel() to
> writel_relaxed().
>
> Also add mmiowb() so that write code doesn't move outside of scope.
>
> Signed-off-by: Sinan Kaya 
> ---
>  drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 ++-
>  drivers/net/ethernet/broadcom/bnxt/bnxt.h | 9 +
>  2 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c 
> b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 1500243..fc8ea0d 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -1922,7 +1922,8 @@ static int bnxt_poll_work(struct bnxt *bp, struct 
> bnxt_napi *bnapi, int budget)
> /* Sync BD data before updating doorbell */
> wmb();
>
> -   bnxt_db_write(bp, db, DB_KEY_TX | prod);
> +   bnxt_db_write_relaxed(bp, db, DB_KEY_TX | prod);
> +   mmiowb();

Sorry for the late review.  mmiowb() is not required here because we
are in NAPI context, so only one CPU will be updating this doorbell.

Other than that, it looks good.

> }
>
> cpr->cp_raw_cons = raw_cons;
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h 
> b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> index 1989c47..5e453b9 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> @@ -1401,6 +1401,15 @@ static inline u32 bnxt_tx_avail(struct bnxt *bp, 
> struct bnxt_tx_ring_info *txr)
> ((txr->tx_prod - txr->tx_cons) & bp->tx_ring_mask);
>  }
>
> +/* For TX and RX ring doorbells with no ordering guarantee*/
> +static inline void bnxt_db_write_relaxed(struct bnxt *bp, void __iomem *db,
> +u32 val)
> +{
> +   writel_relaxed(val, db);
> +   if (bp->flags & BNXT_FLAG_DOUBLE_DB)
> +   writel_relaxed(val, db);
> +}
> +
>  /* For TX and RX ring doorbells */
>  static inline void bnxt_db_write(struct bnxt *bp, void __iomem *db, u32 val)
>  {
> --
> 2.7.4
>


[PATCH v6 3/6] bnx2x: Replace doorbell barrier() with wmb()

2018-03-23 Thread Sinan Kaya
barrier() doesn't guarantee memory writes to be observed by the hardware on
all architectures. barrier() only tells compiler not to move this code
with respect to other read/writes.

If memory write needs to be observed by the HW, wmb() is the right choice.

Signed-off-by: Sinan Kaya 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 3 ++-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index d7c98e8..b97820f 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -4153,7 +4153,8 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct 
net_device *dev)
wmb();
 
txdata->tx_db.data.prod += nbd;
-   barrier();
+   /* make sur edescriptor update is observed by HW */
+   wmb();
 
DOORBELL(bp, txdata->cid, txdata->tx_db.raw);
 
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
index 1e33abd..39af4f8 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
@@ -2591,7 +2591,8 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int 
loopback_mode)
wmb();
 
txdata->tx_db.data.prod += 2;
-   barrier();
+   /* make sure descriptor update is observed by the HW */
+   wmb();
DOORBELL(bp, txdata->cid, txdata->tx_db.raw);
 
mmiowb();
-- 
2.7.4



[PATCH v6 2/6] qlcnic: Eliminate duplicate barriers on weakly-ordered archs

2018-03-23 Thread Sinan Kaya
Code includes wmb() followed by writel(). writel() already has a
barrier on some architectures like arm64.

This ends up CPU observing two barriers back to back before executing
the register write.

Since code already has an explicit barrier call, changing writel() to
writel_relaxed().

Signed-off-by: Sinan Kaya 
Acked-by: Manish Chopra 
---
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c 
b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
index 46b0372..97c146e7 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
@@ -478,7 +478,7 @@ irqreturn_t qlcnic_83xx_clear_legacy_intr(struct 
qlcnic_adapter *adapter)
wmb();
 
/* clear the interrupt trigger control register */
-   writel(0, adapter->isr_int_vec);
+   writel_relaxed(0, adapter->isr_int_vec);
intr_val = readl(adapter->isr_int_vec);
do {
intr_val = readl(adapter->tgt_status_reg);
-- 
2.7.4



[net 8/8] net/mlx5e: Sync netdev vxlan ports at open

2018-03-23 Thread Saeed Mahameed
From: Shahar Klein 

When mlx5_core is loaded it is expected to sync ports
with all vxlan devices so it can support vxlan encap/decap.
This is done via udp_tunnel_get_rx_info(). Currently this
call is set in mlx5e_nic_enable() and if the netdev is not in
NETREG_REGISTERED state it will not be called.

Normally on load the netdev state is not NETREG_REGISTERED
so udp_tunnel_get_rx_info() will not be called.

Moving udp_tunnel_get_rx_info() to mlx5e_open() so
it will be called on netdev UP event and allow encap/decap.

Fixes: 610e89e05c3f ("net/mlx5e: Don't sync netdev state when not registered")
Signed-off-by: Shahar Klein 
Reviewed-by: Roi Dayan 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index e35859657217..9b4827d36e3e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -2572,6 +2572,9 @@ int mlx5e_open(struct net_device *netdev)
mlx5_set_port_admin_status(priv->mdev, MLX5_PORT_UP);
mutex_unlock(>state_lock);
 
+   if (mlx5e_vxlan_allowed(priv->mdev))
+   udp_tunnel_get_rx_info(netdev);
+
return err;
 }
 
@@ -4327,12 +4330,6 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
 #ifdef CONFIG_MLX5_CORE_EN_DCB
mlx5e_dcbnl_init_app(priv);
 #endif
-   /* Device already registered: sync netdev system state */
-   if (mlx5e_vxlan_allowed(mdev)) {
-   rtnl_lock();
-   udp_tunnel_get_rx_info(netdev);
-   rtnl_unlock();
-   }
 
queue_work(priv->wq, >set_rx_mode_work);
 
-- 
2.14.3



[pull request][net 0/8] Mellanox, mlx5 fixes 2018-03-23

2018-03-23 Thread Saeed Mahameed
Hi Dave,

The following series includes fixes for mlx5 netdev and eswitch.

For -stable v4.12
('net/mlx5e: Avoid using the ipv6 stub in the TC offload neigh update path')
('net/mlx5e: Fix traffic being dropped on VF representor')

For -stable v4.13
('net/mlx5e: Fix memory usage issues in offloading TC flows')
('net/mlx5e: Verify coalescing parameters in range')

For -stable v4.14
('net/mlx5e: Don't override vport admin link state in switchdev mode')

For -stable v4.15
('108b2b6d5c02 net/mlx5e: Sync netdev vxlan ports at open')

Please pull and let me know if there's any problem.

Thanks,
Saeed.

---

The following changes since commit 1bfa26ff8c4b7512f4e4efa6df211239223033d4:

  ipv6: fix possible deadlock in rt6_age_examine_exception() (2018-03-23 
13:40:34 -0400)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git 
tags/mlx5-fixes-2018-03-23

for you to fetch changes up to dcbfde231207f7b6e1f5628d59b182198e1cfae2:

  net/mlx5e: Sync netdev vxlan ports at open (2018-03-23 14:23:50 -0700)


mlx5-fixes-2018-03-23


Jianbo Liu (2):
  net/mlx5e: Don't override vport admin link state in switchdev mode
  net/mlx5e: Fix memory usage issues in offloading TC flows

Moshe Shemesh (1):
  net/mlx5e: Verify coalescing parameters in range

Or Gerlitz (3):
  net/mlx5e: Use 32 bits to store VF representor SQ number
  net/mlx5: Make eswitch support to depend on switchdev
  net/mlx5e: Avoid using the ipv6 stub in the TC offload neigh update path

Roi Dayan (1):
  net/mlx5e: Fix traffic being dropped on VF representor

Shahar Klein (1):
  net/mlx5e: Sync netdev vxlan ports at open

 drivers/net/ethernet/mellanox/mlx5/core/Kconfig|  2 +-
 .../net/ethernet/mellanox/mlx5/core/en_ethtool.c   | 17 +++
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  | 13 -
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c   | 34 --
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c| 18 ++--
 5 files changed, 51 insertions(+), 33 deletions(-)


[PATCH v6 1/6] net: qla3xxx: Eliminate duplicate barriers on weakly-ordered archs

2018-03-23 Thread Sinan Kaya
Code includes wmb() followed by writel(). writel() already has a
barrier on some architectures like arm64.

This ends up CPU observing two barriers back to back before executing
the register write.

Since code already has an explicit barrier call, changing code to

wmb()
writel_relaxed()
mmiowb()

for multi-arch support.

Signed-off-by: Sinan Kaya 
---
 drivers/net/ethernet/qlogic/qla3xxx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c 
b/drivers/net/ethernet/qlogic/qla3xxx.c
index 9e5264d..b48f761 100644
--- a/drivers/net/ethernet/qlogic/qla3xxx.c
+++ b/drivers/net/ethernet/qlogic/qla3xxx.c
@@ -1858,8 +1858,9 @@ static void ql_update_small_bufq_prod_index(struct 
ql3_adapter *qdev)
qdev->small_buf_release_cnt -= 8;
}
wmb();
-   writel(qdev->small_buf_q_producer_index,
-   _regs->CommonRegs.rxSmallQProducerIndex);
+   writel_relaxed(qdev->small_buf_q_producer_index,
+  _regs->CommonRegs.rxSmallQProducerIndex);
+   mmiowb();
}
 }
 
-- 
2.7.4



[net 1/8] net/mlx5e: Don't override vport admin link state in switchdev mode

2018-03-23 Thread Saeed Mahameed
From: Jianbo Liu 

The vport admin original link state will be re-applied after returning
back to legacy mode, it is not right to change the admin link state value
when in switchdev mode.

Use direct vport commands to alter logical vport state in netdev
representor open/close flows rather than the administrative eswitch API.

Fixes: 20a1ea674783 ('net/mlx5e: Support VF vport link state control for SRIOV 
switchdev mode')
Signed-off-by: Jianbo Liu 
Reviewed-by: Roi Dayan 
Reviewed-by: Or Gerlitz 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 363d8dcb7f17..0273c233bc85 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -668,7 +668,6 @@ static int mlx5e_rep_open(struct net_device *dev)
struct mlx5e_priv *priv = netdev_priv(dev);
struct mlx5e_rep_priv *rpriv = priv->ppriv;
struct mlx5_eswitch_rep *rep = rpriv->rep;
-   struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
int err;
 
mutex_lock(>state_lock);
@@ -676,8 +675,9 @@ static int mlx5e_rep_open(struct net_device *dev)
if (err)
goto unlock;
 
-   if (!mlx5_eswitch_set_vport_state(esw, rep->vport,
- MLX5_ESW_VPORT_ADMIN_STATE_UP))
+   if (!mlx5_modify_vport_admin_state(priv->mdev,
+   MLX5_QUERY_VPORT_STATE_IN_OP_MOD_ESW_VPORT,
+   rep->vport, MLX5_ESW_VPORT_ADMIN_STATE_UP))
netif_carrier_on(dev);
 
 unlock:
@@ -690,11 +690,12 @@ static int mlx5e_rep_close(struct net_device *dev)
struct mlx5e_priv *priv = netdev_priv(dev);
struct mlx5e_rep_priv *rpriv = priv->ppriv;
struct mlx5_eswitch_rep *rep = rpriv->rep;
-   struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
int ret;
 
mutex_lock(>state_lock);
-   (void)mlx5_eswitch_set_vport_state(esw, rep->vport, 
MLX5_ESW_VPORT_ADMIN_STATE_DOWN);
+   mlx5_modify_vport_admin_state(priv->mdev,
+   MLX5_QUERY_VPORT_STATE_IN_OP_MOD_ESW_VPORT,
+   rep->vport, MLX5_ESW_VPORT_ADMIN_STATE_DOWN);
ret = mlx5e_close_locked(dev);
mutex_unlock(>state_lock);
return ret;
-- 
2.14.3



[net 2/8] net/mlx5e: Use 32 bits to store VF representor SQ number

2018-03-23 Thread Saeed Mahameed
From: Or Gerlitz 

SQs are 32 and not 16 bits, hence it's wrong to use only 16 bits to
store the sq number for which are going to set steering rule, fix that.

Fixes: cb67b832921c ('net/mlx5e: Introduce SRIOV VF representors')
Signed-off-by: Or Gerlitz 
Reviewed-by: Mark Bloch 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 0273c233bc85..738554a6c69f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -209,7 +209,7 @@ static void mlx5e_sqs2vport_stop(struct mlx5_eswitch *esw,
 
 static int mlx5e_sqs2vport_start(struct mlx5_eswitch *esw,
 struct mlx5_eswitch_rep *rep,
-u16 *sqns_array, int sqns_num)
+u32 *sqns_array, int sqns_num)
 {
struct mlx5_flow_handle *flow_rule;
struct mlx5e_rep_priv *rpriv;
@@ -255,9 +255,9 @@ int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv)
struct mlx5e_channel *c;
int n, tc, num_sqs = 0;
int err = -ENOMEM;
-   u16 *sqs;
+   u32 *sqs;
 
-   sqs = kcalloc(priv->channels.num * priv->channels.params.num_tc, 
sizeof(u16), GFP_KERNEL);
+   sqs = kcalloc(priv->channels.num * priv->channels.params.num_tc, 
sizeof(*sqs), GFP_KERNEL);
if (!sqs)
goto out;
 
-- 
2.14.3



[net 6/8] net/mlx5e: Fix memory usage issues in offloading TC flows

2018-03-23 Thread Saeed Mahameed
From: Jianbo Liu 

For NIC flows, the parsed attributes are not freed when we exit
successfully from mlx5e_configure_flower().

There is possible double free for eswitch flows. If error is returned
from rhashtable_insert_fast(), the parse attrs will be freed in
mlx5e_tc_del_flow(), but they will be freed again before exiting
mlx5e_configure_flower().

To fix both issues we do the following:
(1) change the condition that determines if to issue the free call to
check if this flow is NIC flow, or it does not have encap action.
(2) reorder the code such that that the check and free calls are done
before we attempt to add into the hash table.

Fixes: 232c001398ae ('net/mlx5e: Add support to neighbour update flow')
Signed-off-by: Jianbo Liu 
Reviewed-by: Or Gerlitz 
Reviewed-by: Roi Dayan 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index fa86a1466718..ae11678a31e8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -2608,19 +2608,19 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv,
if (err != -EAGAIN)
flow->flags |= MLX5E_TC_FLOW_OFFLOADED;
 
+   if (!(flow->flags & MLX5E_TC_FLOW_ESWITCH) ||
+   !(flow->esw_attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP))
+   kvfree(parse_attr);
+
err = rhashtable_insert_fast(>ht, >node,
 tc->ht_params);
-   if (err)
-   goto err_del_rule;
+   if (err) {
+   mlx5e_tc_del_flow(priv, flow);
+   kfree(flow);
+   }
 
-   if (flow->flags & MLX5E_TC_FLOW_ESWITCH &&
-   !(flow->esw_attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP))
-   kvfree(parse_attr);
return err;
 
-err_del_rule:
-   mlx5e_tc_del_flow(priv, flow);
-
 err_free:
kvfree(parse_attr);
kfree(flow);
-- 
2.14.3



[net 7/8] net/mlx5e: Avoid using the ipv6 stub in the TC offload neigh update path

2018-03-23 Thread Saeed Mahameed
From: Or Gerlitz 

Currently we use the global ipv6_stub var to access the ipv6 global
nd table. This practice gets us to troubles when the stub is only partially
set e.g when ipv6 is loaded under the disabled policy. In this case, as of 
commit
343d60aada5a "ipv6: change ipv6_stub_impl.ipv6_dst_lookup to take net argument"
the stub is not null, but stub->nd_tbl is and we crash.

As we can access directly the ipv6 nd_tbl, the fix is just avoid the
reference through the stub. There is one place in the code were we
issue ipv6 route lookup and keep doing it through the stub, but that
mentioned commit makes sure we get -EAFNOSUPPORT from the stack.

Fixes: 232c001398ae ('net/mlx5e: Add support to neighbour update flow')
Signed-off-by: Or Gerlitz 
Reviewed-by: Aviv Heller 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 6 +++---
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c  | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 9a5a2a7eeab3..500d817d2b0a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -293,7 +293,7 @@ void mlx5e_remove_sqs_fwd_rules(struct mlx5e_priv *priv)
 static void mlx5e_rep_neigh_update_init_interval(struct mlx5e_rep_priv *rpriv)
 {
 #if IS_ENABLED(CONFIG_IPV6)
-   unsigned long ipv6_interval = NEIGH_VAR(_stub->nd_tbl->parms,
+   unsigned long ipv6_interval = NEIGH_VAR(_tbl.parms,
DELAY_PROBE_TIME);
 #else
unsigned long ipv6_interval = ~0UL;
@@ -429,7 +429,7 @@ static int mlx5e_rep_netevent_event(struct notifier_block 
*nb,
case NETEVENT_NEIGH_UPDATE:
n = ptr;
 #if IS_ENABLED(CONFIG_IPV6)
-   if (n->tbl != ipv6_stub->nd_tbl && n->tbl != _tbl)
+   if (n->tbl != _tbl && n->tbl != _tbl)
 #else
if (n->tbl != _tbl)
 #endif
@@ -477,7 +477,7 @@ static int mlx5e_rep_netevent_event(struct notifier_block 
*nb,
 * done per device delay prob time parameter.
 */
 #if IS_ENABLED(CONFIG_IPV6)
-   if (!p->dev || (p->tbl != ipv6_stub->nd_tbl && p->tbl != 
_tbl))
+   if (!p->dev || (p->tbl != _tbl && p->tbl != _tbl))
 #else
if (!p->dev || p->tbl != _tbl)
 #endif
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index ae11678a31e8..43234cabf444 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -963,7 +963,7 @@ void mlx5e_tc_update_neigh_used_value(struct 
mlx5e_neigh_hash_entry *nhe)
tbl = _tbl;
 #if IS_ENABLED(CONFIG_IPV6)
else if (m_neigh->family == AF_INET6)
-   tbl = ipv6_stub->nd_tbl;
+   tbl = _tbl;
 #endif
else
return;
-- 
2.14.3



  1   2   3   4   >