quick mailing list test...

2018-12-01 Thread David Miller


Tweaking some things on vger, please just ignore.


Re: [PATCH bpf-next v2 0/2] sample: xdp1 improvements

2018-12-01 Thread Matteo Croce
On Sat, Dec 1, 2018 at 6:11 AM Alexei Starovoitov
 wrote:
>
> On Sat, Dec 01, 2018 at 01:23:04AM +0100, Matteo Croce wrote:
> > Small improvements to improve the readability and easiness
> > to use of the xdp1 sample.
>
> Applied to bpf-next.
>
> I think that sample code could be more useful if it's wrapped with bash
> script like selftests/test_xdp* tests do.
> At that point it can move to selftests to get 0bot coverage.
> Would you be interested in doing that?
>

It would be nice, but I think that the samples have more urgent issues
right now.
Many examples doesn't compile on my system (Fedora 29, GCC 8.2.1, Clang 7.0.0),
these are the errors that I encounter:

  HOSTCC  /home/matteo/src/kernel/linux/samples/bpf/test_lru_dist
/home/matteo/src/kernel/linux/samples/bpf/test_lru_dist.c:39:8: error:
redefinition of ‘struct list_head’
 struct list_head {
^

  HOSTCC  /home/matteo/src/kernel/linux/samples/bpf/sock_example
In file included from
/home/matteo/src/kernel/linux/samples/bpf/sock_example.c:27:
/usr/include/linux/ip.h:102:2: error: unknown type name ‘__sum16’
  __sum16 check;
  ^~~

  HOSTCC  /home/matteo/src/kernel/linux/samples/bpf/tracex5_user.o
/home/matteo/src/kernel/linux/samples/bpf/tracex5_user.c: In function
‘install_accept_all_seccomp’:
/home/matteo/src/kernel/linux/samples/bpf/tracex5_user.c:17:21: error:
array type has incomplete element type ‘struct sock_filter’
  struct sock_filter filter[] = {
 ^~

  HOSTCC  /home/matteo/src/kernel/linux/samples/bpf/test_cgrp2_attach2.o
/home/matteo/src/kernel/linux/samples/bpf/test_cgrp2_attach2.c: In
function ‘prog_load_cnt’:
/home/matteo/src/kernel/linux/samples/bpf/test_cgrp2_attach2.c:229:3:
error: ‘BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE’ undeclared (first use in
this function); did you mean ‘BPF_MAP_TYPE_CGROUP_STORAGE’?
   BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE,
   ^~

  HOSTCC  /home/matteo/src/kernel/linux/samples/bpf/xdpsock_user.o
/home/matteo/src/kernel/linux/samples/bpf/xdpsock_user.c:59:15: error:
conflicting types for ‘u64’
 typedef __u64 u64;
   ^~~

To be able to compile the samples, I temporarily removed them from the
compilation this way:

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index be0a961450bc..33d7161f2231 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -4,8 +4,6 @@ BPF_SAMPLES_PATH ?= $(abspath $(srctree)/$(src))
 TOOLS_PATH := $(BPF_SAMPLES_PATH)/../../tools

 # List of programs to build
-hostprogs-y := test_lru_dist
-hostprogs-y += sock_example
 hostprogs-y += fds_example
 hostprogs-y += sockex1
 hostprogs-y += sockex2
@@ -14,7 +12,6 @@ hostprogs-y += tracex1
 hostprogs-y += tracex2
 hostprogs-y += tracex3
 hostprogs-y += tracex4
-hostprogs-y += tracex5
 hostprogs-y += tracex6
 hostprogs-y += tracex7
 hostprogs-y += test_probe_write_user
@@ -26,7 +23,6 @@ hostprogs-y += map_perf_test
 hostprogs-y += test_overhead
 hostprogs-y += test_cgrp2_array_pin
 hostprogs-y += test_cgrp2_attach
-hostprogs-y += test_cgrp2_attach2
 hostprogs-y += test_cgrp2_sock
 hostprogs-y += test_cgrp2_sock2
 hostprogs-y += xdp1
@@ -49,7 +45,6 @@ hostprogs-y += xdp_rxq_info
 hostprogs-y += syscall_tp
 hostprogs-y += cpustat
 hostprogs-y += xdp_adjust_tail
-hostprogs-y += xdpsock
 hostprogs-y += xdp_fwd
 hostprogs-y += task_fd_query
 hostprogs-y += xdp_sample_pkts

Regards,
-- 
Matteo Croce
per aspera ad upstream


Re: [PATCH v1 net-next 05/14] octeontx2-af: Restrict TL1 allocation and configuration

2018-12-01 Thread David Miller
From: Jerin Jacob 
Date: Sat,  1 Dec 2018 14:43:54 +0530

> @@ -987,6 +997,76 @@ static void nix_reset_tx_linkcfg(struct rvu *rvu, int 
> blkaddr,
>   NIX_AF_TL3_TL2X_LINKX_CFG(schq, link), 0x00);
>  }
>  
> +static int
> +rvu_get_tl1_schqs(struct rvu *rvu,
> +   int blkaddr,
> +   u16 pcifunc,
> +   u16 *schq_list,
> +   u16 *schq_cnt)

Please pack these lines as densely with arguments as 80 columns will allow.


Re: [PATCH v1 net-next 02/14] octeontx2-af: Add response for RSS flow key cfg message

2018-12-01 Thread David Miller
From: Jerin Jacob 
Date: Sat,  1 Dec 2018 14:43:51 +0530

> +#define FLOW_KEY_TYPE_PORT   BIT(0)
> +#define FLOW_KEY_TYPE_IPV4   BIT(1)
> +#define FLOW_KEY_TYPE_IPV6   BIT(2)
> +#define FLOW_KEY_TYPE_TCPBIT(3)
> +#define FLOW_KEY_TYPE_UDPBIT(4)
> +#define FLOW_KEY_TYPE_SCTP   BIT(5)

This is asking for serious global namespace collisions, as we have
various FLOW_* definitions coming from include/uapi/linux/pkt_cls.h
for example.

Please put some appropriate driver prefix to these macro names.

Thanks.



[PATCH bpf-next] bpf: Fix memleak in aux->func_info and aux->btf

2018-12-01 Thread Martin KaFai Lau
The aux->func_info and aux->btf are leaked in the error out cases
during bpf_prog_load().  This patch fixes it.

Fixes: ba64e7d85252 ("bpf: btf: support proper non-jit func info")
Cc: Yonghong Song 
Signed-off-by: Martin KaFai Lau 
Acked-by: Yonghong Song 
---
 kernel/bpf/syscall.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index f9554d9a14e1..4445d0d084d8 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1560,6 +1560,8 @@ static int bpf_prog_load(union bpf_attr *attr, union 
bpf_attr __user *uattr)
return err;
 
 free_used_maps:
+   kvfree(prog->aux->func_info);
+   btf_put(prog->aux->btf);
bpf_prog_kallsyms_del_subprogs(prog);
free_used_maps(prog->aux);
 free_prog:
-- 
2.17.1



Re: [Bug 201829] New: Failed build kernel with nat

2018-12-01 Thread David Miller


Stephen please actually read the reports your forward here.

This is a report about arch/x86/lib/inat.c which is a set of CPU
instruction attributes and has nothing to do with networkig.


[PATCH] samples: bpf: fix: seg fault with NULL pointer arg

2018-12-01 Thread Daniel T. Lee
When NULL pointer accidentally passed to write_kprobe_events,
due to strlen(NULL), segmentation fault happens.
Changed code returns -1 to deal with this situation.

Bug issued with Smatch, static analysis.

Signed-off-by: Daniel T. Lee 
---
 samples/bpf/bpf_load.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/samples/bpf/bpf_load.c b/samples/bpf/bpf_load.c
index 434ea34a5954..c670bd2200d2 100644
--- a/samples/bpf/bpf_load.c
+++ b/samples/bpf/bpf_load.c
@@ -58,7 +58,9 @@ static int write_kprobe_events(const char *val)
 {
int fd, ret, flags;
 
-   if ((val != NULL) && (val[0] == '\0'))
+   if (val == NULL)
+   return -1;
+   else if ((val != NULL) && (val[0] == '\0'))
flags = O_WRONLY | O_TRUNC;
else
flags = O_WRONLY | O_APPEND;
-- 
2.17.1



Re: [PATCH bpf-next] bpf: allow BPF read access to qdisc pkt_len

2018-12-01 Thread Willem de Bruijn
On Fri, Nov 30, 2018 at 7:41 PM Daniel Borkmann  wrote:
>
> On 12/01/2018 12:42 AM, Willem de Bruijn wrote:
> > On Fri, Nov 30, 2018 at 5:48 PM Song Liu  wrote:
> >>
> >> On Fri, Nov 30, 2018 at 12:09 PM Willem de Bruijn
> >>  wrote:
> >>>
> >>> From: Petar Penkov 
> >>>
> >>> The pkt_len field in qdisc_skb_cb stores the skb length as it will
> >>> appear on the wire after segmentation. For byte accounting, this value
> >>> is more accurate than skb->len. It is computed on entry to the TC
> >>> layer, so only valid there.
> >>>
> >>> Allow read access to this field from BPF tc classifier and action
> >>> programs. The implementation is analogous to tc_classid, aside from
> >>> restricting to read access.
> >>>
> >>> Signed-off-by: Petar Penkov 
> >>> Signed-off-by: Vlad Dumitrescu 
> >>> Signed-off-by: Willem de Bruijn 
> >>> ---
> >>>  include/uapi/linux/bpf.h|  1 +
> >>>  net/core/filter.c   | 16 +++
> >>>  tools/include/uapi/linux/bpf.h  |  1 +
> >>>  tools/testing/selftests/bpf/test_verifier.c | 32 +
> >>>  4 files changed, 50 insertions(+)
> >>
> >> Please split this into 3 patches:
> >> 1 for include/uapi/linux/bpf.h and filter.c
> >> 1 for tools/include/uapi/linux/bpf.h
> >> 1 for tools/testing/selftests/bpf/test_verifier.c
> >>
> >> Other than this
> >> Acked-by: Song Liu 
> >
> > Thanks for the fast review.
> >
> > I'm happy to resend in three parts, of course, but am curious: what is
> > the rationale for splitting this up?
> >
> > This patch follows the process for commit  f11216b24219 ("bpf: add
> > skb->tstamp r/w access from tc clsact and cg skb progs"), which went
> > in as a single patch just last week.
>
> Yeah, I think it's fine as is, one small thing I'm wondering though is
> given that we now would have both 'skb->len' and 'skb->pkt_len', would
> it be more intuitive for a BPF program developer to distinguish the two
> by having the latter named e.g. 'skb->wire_len' so it's slightly more
> obvious that it's including header size at post-segmentation?

Yes, I actually had considered qdisc_pkt_len to drive home the point
that this is derived from, and thus defined by, qdisc_pkt_len_init. But
wire_len is a much more intuitive description. I'll send a v2. Thanks!


[Patch net] mlx5: check for malformed packets

2018-12-01 Thread Cong Wang
is_last_ethertype_ip() is used to check IP/IPv6 protocol before
parsing IP/IPv6 headers.

But __vlan_get_protocol() is only bound to skb->len, a malicious
packet could exhaust all skb->len by inserting sufficient ETH_P_8021AD
headers, and it may not even contain an IP/IPv6 header at all, so we
have to check if we are still safe to continue to parse IP/IPv6 header.
If not, treat it as non-IP packet.

This should not cause any crash as we stil have tail room in skb,
but we can't just rely on it either.

Cc: Tariq Toukan 
Cc: Saeed Mahameed 
Signed-off-by: Cong Wang 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index 624eed345b5d..1e505013ebfd 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -693,7 +693,18 @@ static inline bool is_last_ethertype_ip(struct sk_buff 
*skb, int *network_depth,
 {
*proto = ((struct ethhdr *)skb->data)->h_proto;
*proto = __vlan_get_protocol(skb, *proto, network_depth);
-   return (*proto == htons(ETH_P_IP) || *proto == htons(ETH_P_IPV6));
+
+   if (*proto == htons(ETH_P_IP)) {
+   if (unlikely(*network_depth > skb->len - sizeof(struct iphdr)))
+   return false;
+   return true;
+   } else if (*proto == htons(ETH_P_IPV6)) {
+   if (unlikely(*network_depth > skb->len - sizeof(struct 
ipv6hdr)))
+   return false;
+   return true;
+   }
+
+   return false;
 }
 
 static inline void mlx5e_enable_ecn(struct mlx5e_rq *rq, struct sk_buff *skb)
-- 
2.19.1



Re: [PATCH net] bpf: uninitialized variables in test code

2018-12-01 Thread Alexei Starovoitov
On Sat, Dec 01, 2018 at 08:12:34PM +, Roman Gushchin wrote:
> 
> From dc70ddb39c2f8d87d64b8d0fd71f4baa956d5f50 Mon Sep 17 00:00:00 2001
> From: Roman Gushchin 
> Date: Sat, 1 Dec 2018 10:39:44 -0800
> Subject: [PATCH v2 bpf] bpf: refactor bpf_test_run() to separate own failures
>  and test program result
> 
> After commit f42ee093be29 ("bpf/test_run: support cgroup local
> storage") the bpf_test_run() function may fail with -ENOMEM, if
> it's not possible to allocate memory for a cgroup local storage.
> 
> This error shouldn't be mixed with the return value of the testing
> program. Let's add an additional argument with a pointer where to
> store the testing program's result; and make bpf_test_run()
> return either 0 or -ENOMEM.
> 
> Fixes: f42ee093be29 ("bpf/test_run: support cgroup local storage")
> Reported-by: Dan Carpenter 
> Suggested-by: Alexei Starovoitov 
> Signed-off-by: Roman Gushchin 
> Cc: Daniel Borkmann 
> Cc: Alexei Starovoitov 

Applied to bpf tree. Thanks!



Re: [PATCH net] bpf: uninitialized variables in test code

2018-12-01 Thread Roman Gushchin
On Sat, Dec 01, 2018 at 11:28:46AM -0800, Alexei Starovoitov wrote:
> On Sat, Dec 01, 2018 at 07:13:50PM +, Roman Gushchin wrote:
> > On Fri, Nov 30, 2018 at 02:58:03PM -0800, Alexei Starovoitov wrote:
> > > On Thu, Nov 29, 2018 at 01:27:03PM +0300, Dan Carpenter wrote:
> > > > Smatch complains that if bpf_test_run() fails with -ENOMEM at the
> > > > begining then the "duration" is uninitialized.  We then copy the
> > > > unintialized variables to the user inside the bpf_test_finish()
> > > > function.  The functions require CAP_SYS_ADMIN so it's not really an
> > > > information leak.
> > > > 
> > > > Fixes: 1cf1cae963c2 ("bpf: introduce BPF_PROG_TEST_RUN command")
> > > > Signed-off-by: Dan Carpenter 
> > > 
> > > That is incorrect fixes tag.
> > > It should be pointing to commit f42ee093be29 ("bpf/test_run: support 
> > > cgroup local storage")
> > > 
> > > bpf_test_run() can only return the value that bpf program returned.
> > > It cannot return -ENOMEM.
> > > That code needs to be refactored.
> > > I think the proper way for bpf_test_run() would be to return 0 or -ENOMEM
> > > and store bpf's retval into extra pointer.
> > > Proper checks need to be added in the callers (bpf_prog_test_run_skb, 
> > > etc).
> > 
> > Makes total sense. How about this patch?
> 
> Thanks for the quick fix!
> 
> > Thanks!
> > 
> > --
> > 
> > From a2832f56c621d7809da8d4196877fa01621055f5 Mon Sep 17 00:00:00 2001
> > From: Roman Gushchin 
> > Date: Sat, 1 Dec 2018 10:39:44 -0800
> > Subject: [PATCH bpf] bpf: refactor bpf_test_run() to separate own failures 
> > and
> >  test program result
> > 
> > After commit f42ee093be29 ("bpf/test_run: support cgroup local
> > storage") the bpf_test_run() function may fail with -ENOMEM, if
> > it's not possible to allocate memory for a cgroup local storage.
> > 
> > This error shouldn't be mixed with the return value of the testing
> > program. Let's add an additional argument with a pointer where to
> > store the testing program's result; and make bpf_test_run()
> > return either 0 or -ENOMEM.
> > 
> > Fixes: f42ee093be29 ("bpf/test_run: support cgroup local storage")
> > Reported-by: Dan Carpenter 
> > Suggested-by: Alexei Starovoitov 
> > Signed-off-by: Roman Gushchin 
> > Cc: Daniel Borkmann 
> > Cc: Alexei Starovoitov 
> > ---
> >  net/bpf/test_run.c | 21 +++--
> >  1 file changed, 15 insertions(+), 6 deletions(-)
> > 
> > diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
> > index c89c22c49015..8bce7d8d00d9 100644
> > --- a/net/bpf/test_run.c
> > +++ b/net/bpf/test_run.c
> > @@ -28,12 +28,13 @@ static __always_inline u32 bpf_test_run_one(struct 
> > bpf_prog *prog, void *ctx,
> > return ret;
> >  }
> >  
> > -static u32 bpf_test_run(struct bpf_prog *prog, void *ctx, u32 repeat, u32 
> > *time)
> > +static u32 bpf_test_run(struct bpf_prog *prog, void *ctx, u32 repeat, u32 
> > *ret,
> > +   u32 *time)
> 
> may be 'int' return value?

Sure.
> 
> >  {
> > struct bpf_cgroup_storage *storage[MAX_BPF_CGROUP_STORAGE_TYPE] = { 0 };
> > enum bpf_cgroup_storage_type stype;
> > u64 time_start, time_spent = 0;
> > -   u32 ret = 0, i;
> > +   u32 i;
> >  
> > for_each_cgroup_storage_type(stype) {
> > storage[stype] = bpf_cgroup_storage_alloc(prog, stype);
> > @@ -49,7 +50,7 @@ static u32 bpf_test_run(struct bpf_prog *prog, void *ctx, 
> > u32 repeat, u32 *time)
> > repeat = 1;
> > time_start = ktime_get_ns();
> > for (i = 0; i < repeat; i++) {
> > -   ret = bpf_test_run_one(prog, ctx, storage);
> > +   *ret = bpf_test_run_one(prog, ctx, storage);
> > if (need_resched()) {
> > if (signal_pending(current))
> > break;
> > @@ -65,7 +66,7 @@ static u32 bpf_test_run(struct bpf_prog *prog, void *ctx, 
> > u32 repeat, u32 *time)
> > for_each_cgroup_storage_type(stype)
> > bpf_cgroup_storage_free(storage[stype]);
> >  
> > -   return ret;
> > +   return 0;
> >  }
> >  
> >  static int bpf_test_finish(const union bpf_attr *kattr,
> > @@ -165,7 +166,12 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog, const 
> > union bpf_attr *kattr,
> > __skb_push(skb, hh_len);
> > if (is_direct_pkt_access)
> > bpf_compute_data_pointers(skb);
> > -   retval = bpf_test_run(prog, skb, repeat, );
> > +   ret = bpf_test_run(prog, skb, repeat, , );
> > +   if (ret) {
> > +   kfree(data);
> 
> should probably be kfree_skb(skb); instead ?

Agree. An updated version below.

Thanks!

--

>From dc70ddb39c2f8d87d64b8d0fd71f4baa956d5f50 Mon Sep 17 00:00:00 2001
From: Roman Gushchin 
Date: Sat, 1 Dec 2018 10:39:44 -0800
Subject: [PATCH v2 bpf] bpf: refactor bpf_test_run() to separate own failures
 and test program result

After commit f42ee093be29 ("bpf/test_run: support cgroup local
storage") the bpf_test_run() function may fail with -ENOMEM, if
it's not possible to allocate memory for a cgroup local storage.


Fw: [Bug 201829] New: Failed build kernel with nat

2018-12-01 Thread Stephen Hemminger



Begin forwarded message:

Date: Sat, 01 Dec 2018 17:20:33 +
From: bugzilla-dae...@bugzilla.kernel.org
To: step...@networkplumber.org
Subject: [Bug 201829] New: Failed build kernel with nat


https://bugzilla.kernel.org/show_bug.cgi?id=201829

Bug ID: 201829
   Summary: Failed build kernel with nat
   Product: Networking
   Version: 2.5
Kernel Version: 4.19.6
  Hardware: x86-64
OS: Linux
  Tree: Mainline
Status: NEW
  Severity: normal
  Priority: P1
 Component: Other
  Assignee: step...@networkplumber.org
  Reporter: o...@ow1.in
Regression: No

Created attachment 279769
  --> https://bugzilla.kernel.org/attachment.cgi?id=279769=edit  
Kernel configuration

Kernel building with my old configuration failing on inat_primary_table. I cant
find find defining of this table in code. Last successfully builded version is
4.19.0.

workbook /usr/src/linux # make
  CALLscripts/checksyscalls.sh
  DESCEND  objtool
  CC   /usr/src/linux-4.19.2/tools/objtool/arch/x86/decode.o
In file included from arch/x86/decode.c:23:0:
arch/x86/lib/inat.c: В функции «inat_get_opcode_attribute»:
arch/x86/lib/inat.c:29:9: ошибка: «inat_primary_table» не описан (первое
использование в этой функции)
  return inat_primary_table[opcode];
 ^~
arch/x86/lib/inat.c:29:9: замечание: сообщение о каждом неописанном
идентификаторе выдается один раз в каждой функции, где он встречается
arch/x86/lib/inat.c: В функции «inat_get_escape_attribute»:
arch/x86/lib/inat.c:48:10: ошибка: «inat_escape_tables» undeclared (first use
in this function); did you mean «inat_escape_id»?
  table = inat_escape_tables[n][0];
  ^~
  inat_escape_id
arch/x86/lib/inat.c:44:6: ошибка: переменная «n» определена, но не используется
[-Werror=unused-but-set-variable]
  int n;
  ^
arch/x86/lib/inat.c: В функции «inat_get_group_attribute»:
arch/x86/lib/inat.c:67:10: ошибка: «inat_group_tables» undeclared (first use in
this function); did you mean «inat_group_id»?
  table = inat_group_tables[n][0];
  ^
  inat_group_id
arch/x86/lib/inat.c:63:6: ошибка: переменная «n» определена, но не используется
[-Werror=unused-but-set-variable]
  int n;
  ^
arch/x86/lib/inat.c: В функции «inat_get_avx_attribute»:
arch/x86/lib/inat.c:86:10: ошибка: «inat_avx_tables» не описан (первое
использование в этой функции)
  table = inat_avx_tables[vex_m][0];
  ^~~
In file included from arch/x86/decode.c:23:0:
arch/x86/lib/inat.c: В функции «inat_get_opcode_attribute»:
arch/x86/lib/inat.c:30:1: ошибка: управление достигает конца не-void функции
[-Werror=return-type]
 }
 ^
cc1: все предупреждения считаются ошибками
mv: не удалось выполнить stat для
'/usr/src/linux-4.19.2/tools/objtool/arch/x86/.decode.o.tmp': Нет такого файла
или каталога
make[4]: *** [/usr/src/linux-4.19.2/tools/build/Makefile.build:97:
/usr/src/linux-4.19.2/tools/objtool/arch/x86/decode.o] Ошибка 1
make[3]: *** [/usr/src/linux-4.19.2/tools/build/Makefile.build:139: arch/x86]
Ошибка 2
make[2]: *** [Makefile:46: /usr/src/linux-4.19.2/tools/objtool/objtool-in.o]
Ошибка 2
make[1]: *** [Makefile:63: objtool] Ошибка 2
make: *** [Makefile:1644: tools/objtool] Error 2

-- 
You are receiving this mail because:
You are the assignee for the bug.


Re: [PATCH net] bpf: uninitialized variables in test code

2018-12-01 Thread Alexei Starovoitov
On Sat, Dec 01, 2018 at 07:13:50PM +, Roman Gushchin wrote:
> On Fri, Nov 30, 2018 at 02:58:03PM -0800, Alexei Starovoitov wrote:
> > On Thu, Nov 29, 2018 at 01:27:03PM +0300, Dan Carpenter wrote:
> > > Smatch complains that if bpf_test_run() fails with -ENOMEM at the
> > > begining then the "duration" is uninitialized.  We then copy the
> > > unintialized variables to the user inside the bpf_test_finish()
> > > function.  The functions require CAP_SYS_ADMIN so it's not really an
> > > information leak.
> > > 
> > > Fixes: 1cf1cae963c2 ("bpf: introduce BPF_PROG_TEST_RUN command")
> > > Signed-off-by: Dan Carpenter 
> > 
> > That is incorrect fixes tag.
> > It should be pointing to commit f42ee093be29 ("bpf/test_run: support cgroup 
> > local storage")
> > 
> > bpf_test_run() can only return the value that bpf program returned.
> > It cannot return -ENOMEM.
> > That code needs to be refactored.
> > I think the proper way for bpf_test_run() would be to return 0 or -ENOMEM
> > and store bpf's retval into extra pointer.
> > Proper checks need to be added in the callers (bpf_prog_test_run_skb, etc).
> 
> Makes total sense. How about this patch?

Thanks for the quick fix!

> Thanks!
> 
> --
> 
> From a2832f56c621d7809da8d4196877fa01621055f5 Mon Sep 17 00:00:00 2001
> From: Roman Gushchin 
> Date: Sat, 1 Dec 2018 10:39:44 -0800
> Subject: [PATCH bpf] bpf: refactor bpf_test_run() to separate own failures and
>  test program result
> 
> After commit f42ee093be29 ("bpf/test_run: support cgroup local
> storage") the bpf_test_run() function may fail with -ENOMEM, if
> it's not possible to allocate memory for a cgroup local storage.
> 
> This error shouldn't be mixed with the return value of the testing
> program. Let's add an additional argument with a pointer where to
> store the testing program's result; and make bpf_test_run()
> return either 0 or -ENOMEM.
> 
> Fixes: f42ee093be29 ("bpf/test_run: support cgroup local storage")
> Reported-by: Dan Carpenter 
> Suggested-by: Alexei Starovoitov 
> Signed-off-by: Roman Gushchin 
> Cc: Daniel Borkmann 
> Cc: Alexei Starovoitov 
> ---
>  net/bpf/test_run.c | 21 +++--
>  1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
> index c89c22c49015..8bce7d8d00d9 100644
> --- a/net/bpf/test_run.c
> +++ b/net/bpf/test_run.c
> @@ -28,12 +28,13 @@ static __always_inline u32 bpf_test_run_one(struct 
> bpf_prog *prog, void *ctx,
>   return ret;
>  }
>  
> -static u32 bpf_test_run(struct bpf_prog *prog, void *ctx, u32 repeat, u32 
> *time)
> +static u32 bpf_test_run(struct bpf_prog *prog, void *ctx, u32 repeat, u32 
> *ret,
> + u32 *time)

may be 'int' return value?

>  {
>   struct bpf_cgroup_storage *storage[MAX_BPF_CGROUP_STORAGE_TYPE] = { 0 };
>   enum bpf_cgroup_storage_type stype;
>   u64 time_start, time_spent = 0;
> - u32 ret = 0, i;
> + u32 i;
>  
>   for_each_cgroup_storage_type(stype) {
>   storage[stype] = bpf_cgroup_storage_alloc(prog, stype);
> @@ -49,7 +50,7 @@ static u32 bpf_test_run(struct bpf_prog *prog, void *ctx, 
> u32 repeat, u32 *time)
>   repeat = 1;
>   time_start = ktime_get_ns();
>   for (i = 0; i < repeat; i++) {
> - ret = bpf_test_run_one(prog, ctx, storage);
> + *ret = bpf_test_run_one(prog, ctx, storage);
>   if (need_resched()) {
>   if (signal_pending(current))
>   break;
> @@ -65,7 +66,7 @@ static u32 bpf_test_run(struct bpf_prog *prog, void *ctx, 
> u32 repeat, u32 *time)
>   for_each_cgroup_storage_type(stype)
>   bpf_cgroup_storage_free(storage[stype]);
>  
> - return ret;
> + return 0;
>  }
>  
>  static int bpf_test_finish(const union bpf_attr *kattr,
> @@ -165,7 +166,12 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog, const 
> union bpf_attr *kattr,
>   __skb_push(skb, hh_len);
>   if (is_direct_pkt_access)
>   bpf_compute_data_pointers(skb);
> - retval = bpf_test_run(prog, skb, repeat, );
> + ret = bpf_test_run(prog, skb, repeat, , );
> + if (ret) {
> + kfree(data);

should probably be kfree_skb(skb); instead ?

> + kfree(sk);
> + return ret;
> + }
>   if (!is_l2) {
>   if (skb_headroom(skb) < hh_len) {
>   int nhead = HH_DATA_ALIGN(hh_len - skb_headroom(skb));
> @@ -212,11 +218,14 @@ int bpf_prog_test_run_xdp(struct bpf_prog *prog, const 
> union bpf_attr *kattr,
>   rxqueue = __netif_get_rx_queue(current->nsproxy->net_ns->loopback_dev, 
> 0);
>   xdp.rxq = >xdp_rxq;
>  
> - retval = bpf_test_run(prog, , repeat, );
> + ret = bpf_test_run(prog, , repeat, , );
> + if (ret)
> + goto out;
>   if (xdp.data != data + XDP_PACKET_HEADROOM + NET_IP_ALIGN ||
>   xdp.data_end != xdp.data + size)
>   size = xdp.data_end - 

Re: [PATCH net] bpf: uninitialized variables in test code

2018-12-01 Thread Roman Gushchin
On Fri, Nov 30, 2018 at 02:58:03PM -0800, Alexei Starovoitov wrote:
> On Thu, Nov 29, 2018 at 01:27:03PM +0300, Dan Carpenter wrote:
> > Smatch complains that if bpf_test_run() fails with -ENOMEM at the
> > begining then the "duration" is uninitialized.  We then copy the
> > unintialized variables to the user inside the bpf_test_finish()
> > function.  The functions require CAP_SYS_ADMIN so it's not really an
> > information leak.
> > 
> > Fixes: 1cf1cae963c2 ("bpf: introduce BPF_PROG_TEST_RUN command")
> > Signed-off-by: Dan Carpenter 
> 
> That is incorrect fixes tag.
> It should be pointing to commit f42ee093be29 ("bpf/test_run: support cgroup 
> local storage")
> 
> bpf_test_run() can only return the value that bpf program returned.
> It cannot return -ENOMEM.
> That code needs to be refactored.
> I think the proper way for bpf_test_run() would be to return 0 or -ENOMEM
> and store bpf's retval into extra pointer.
> Proper checks need to be added in the callers (bpf_prog_test_run_skb, etc).

Makes total sense. How about this patch?

Thanks!

--

>From a2832f56c621d7809da8d4196877fa01621055f5 Mon Sep 17 00:00:00 2001
From: Roman Gushchin 
Date: Sat, 1 Dec 2018 10:39:44 -0800
Subject: [PATCH bpf] bpf: refactor bpf_test_run() to separate own failures and
 test program result

After commit f42ee093be29 ("bpf/test_run: support cgroup local
storage") the bpf_test_run() function may fail with -ENOMEM, if
it's not possible to allocate memory for a cgroup local storage.

This error shouldn't be mixed with the return value of the testing
program. Let's add an additional argument with a pointer where to
store the testing program's result; and make bpf_test_run()
return either 0 or -ENOMEM.

Fixes: f42ee093be29 ("bpf/test_run: support cgroup local storage")
Reported-by: Dan Carpenter 
Suggested-by: Alexei Starovoitov 
Signed-off-by: Roman Gushchin 
Cc: Daniel Borkmann 
Cc: Alexei Starovoitov 
---
 net/bpf/test_run.c | 21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index c89c22c49015..8bce7d8d00d9 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -28,12 +28,13 @@ static __always_inline u32 bpf_test_run_one(struct bpf_prog 
*prog, void *ctx,
return ret;
 }
 
-static u32 bpf_test_run(struct bpf_prog *prog, void *ctx, u32 repeat, u32 
*time)
+static u32 bpf_test_run(struct bpf_prog *prog, void *ctx, u32 repeat, u32 *ret,
+   u32 *time)
 {
struct bpf_cgroup_storage *storage[MAX_BPF_CGROUP_STORAGE_TYPE] = { 0 };
enum bpf_cgroup_storage_type stype;
u64 time_start, time_spent = 0;
-   u32 ret = 0, i;
+   u32 i;
 
for_each_cgroup_storage_type(stype) {
storage[stype] = bpf_cgroup_storage_alloc(prog, stype);
@@ -49,7 +50,7 @@ static u32 bpf_test_run(struct bpf_prog *prog, void *ctx, u32 
repeat, u32 *time)
repeat = 1;
time_start = ktime_get_ns();
for (i = 0; i < repeat; i++) {
-   ret = bpf_test_run_one(prog, ctx, storage);
+   *ret = bpf_test_run_one(prog, ctx, storage);
if (need_resched()) {
if (signal_pending(current))
break;
@@ -65,7 +66,7 @@ static u32 bpf_test_run(struct bpf_prog *prog, void *ctx, u32 
repeat, u32 *time)
for_each_cgroup_storage_type(stype)
bpf_cgroup_storage_free(storage[stype]);
 
-   return ret;
+   return 0;
 }
 
 static int bpf_test_finish(const union bpf_attr *kattr,
@@ -165,7 +166,12 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog, const 
union bpf_attr *kattr,
__skb_push(skb, hh_len);
if (is_direct_pkt_access)
bpf_compute_data_pointers(skb);
-   retval = bpf_test_run(prog, skb, repeat, );
+   ret = bpf_test_run(prog, skb, repeat, , );
+   if (ret) {
+   kfree(data);
+   kfree(sk);
+   return ret;
+   }
if (!is_l2) {
if (skb_headroom(skb) < hh_len) {
int nhead = HH_DATA_ALIGN(hh_len - skb_headroom(skb));
@@ -212,11 +218,14 @@ int bpf_prog_test_run_xdp(struct bpf_prog *prog, const 
union bpf_attr *kattr,
rxqueue = __netif_get_rx_queue(current->nsproxy->net_ns->loopback_dev, 
0);
xdp.rxq = >xdp_rxq;
 
-   retval = bpf_test_run(prog, , repeat, );
+   ret = bpf_test_run(prog, , repeat, , );
+   if (ret)
+   goto out;
if (xdp.data != data + XDP_PACKET_HEADROOM + NET_IP_ALIGN ||
xdp.data_end != xdp.data + size)
size = xdp.data_end - xdp.data;
ret = bpf_test_finish(kattr, uattr, xdp.data, size, retval, duration);
+out:
kfree(data);
return ret;
 }
-- 
2.17.2



Re: [PATCHv3 bpf 1/2] bpf: Support sk lookup in netns with id 0

2018-12-01 Thread Joe Stringer
On Fri, 30 Nov 2018 at 17:36, Alexei Starovoitov
 wrote:
>
> On Fri, Nov 30, 2018 at 03:32:20PM -0800, Joe Stringer wrote:
> > David Ahern and Nicolas Dichtel report that the handling of the netns id
> > 0 is incorrect for the BPF socket lookup helpers: rather than finding
> > the netns with id 0, it is resolving to the current netns. This renders
> > the netns_id 0 inaccessible.
> >
> > To fix this, adjust the API for the netns to treat all negative s32
> > values as a lookup in the current netns (including u64 values which when
> > truncated to s32 become negative), while any values with a positive
> > value in the signed 32-bit integer space would result in a lookup for a
> > socket in the netns corresponding to that id. As before, if the netns
> > with that ID does not exist, no socket will be found. Any netns outside
> > of these ranges will fail to find a corresponding socket, as those
> > values are reserved for future usage.
> >
> > Signed-off-by: Joe Stringer 
> > Acked-by: Nicolas Dichtel 
>
> Applied both. Thanks everyone.
>
> Joe, please provide a cover letter 0/N next time for the series
> or if they're really separate patches submit them one by one.

OK thanks, I'll keep that in mind.


Re: [PATCH 1/2] net: linkwatch: send change uevent on link changes

2018-12-01 Thread Stephen Hemminger
On Sat, 1 Dec 2018 17:00:21 +0100
Jouke Witteveen  wrote:

> Make it easy for userspace to respond to acquisition/loss of carrier.
> The uevent is picked up by udev and, on systems with systemd, the
> device unit of the interface announces a configuration reload.
> 
> Signed-off-by: Jouke Witteveen 

Makes sense. I am also working on tracepoints for netdev changes.

Reviewed-by: Stephen Hemminger 


Re: [PATCH net-next,v4 12/12] qede: use ethtool_rx_flow_rule() to remove duplicated parser code

2018-12-01 Thread kbuild test robot
Hi Pablo,

I love your patch! Perhaps something to improve:

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

url:
https://github.com/0day-ci/linux/commits/Pablo-Neira-Ayuso/add-flow_rule-infrastructure/20181130-204709
config: x86_64-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   drivers/scsi/libfc/fc_libfc.c:209:26: warning: cast to restricted __be16
   drivers/scsi/libfc/fc_libfc.c:209:26: warning: cast to restricted __be16
   drivers/scsi/libfc/fc_libfc.c:209:26: warning: cast to restricted __be16
   drivers/scsi/libfc/fc_libfc.c:209:26: warning: cast to restricted __be16
   drivers/scsi/libfc/fc_libfc.c:209:24: warning: incorrect type in assignment 
(different base types)
   drivers/scsi/libfc/fc_libfc.c:209:24:expected restricted __be16 
[usertype] fh_seq_cnt
   drivers/scsi/libfc/fc_libfc.c:209:24:got int
   drivers/scsi/libfc/fc_libfc.c:299:17: error: incompatible types in 
comparison expression (different address spaces)
   drivers/scsi/libfc/fc_libfc.c:301:17: error: incompatible types in 
comparison expression (different address spaces)
   drivers/net/wireless/intel/iwlwifi/fw/file.h:287:19: warning: mixed 
bitwiseness
   drivers/net/wireless/intel/iwlwifi/fw/file.h:413:19: warning: mixed 
bitwiseness
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   drivers/staging/android/ion/ion_carveout_heap.c:106:17: warning: symbol 
'ion_carveout_heap_create' was not declared. Should it be static?
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   drivers/net/wireless/ath/ath9k/eeprom_def.c:138:9: warning: cast to 
restricted __le16
   drivers/net/wireless/ath/ath9k/eeprom_def.c:138:9: warning: cast from 
restricted __le32
   drivers/net/wireless/ath/ath9k/eeprom_def.c:139:9: warning: cast to 
restricted __le16
   drivers/net/wireless/ath/ath9k/eeprom_def.c:139:9: warning: cast from 
restricted __le32
   drivers/net/wireless/ath/ath9k/eeprom_def.c:140:9: warning: cast to 
restricted __le16
   drivers/net/wireless/ath/ath9k/eeprom_def.c:140:9: warning: cast from 
restricted __le32
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
   drivers/staging/android/ion/ion_chunk_heap.c:111:17: warning: symbol 
'ion_chunk_heap_create' was not declared. Should it be static?
   include/linux/slab.h:332:43: 

[PATCH 2/2] Documentation: bring operstate documentation up-to-date

2018-12-01 Thread Jouke Witteveen
Signed-off-by: Jouke Witteveen 
---
 Documentation/networking/operstates.txt | 13 -
 net/sched/sch_generic.c |  2 +-
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/Documentation/networking/operstates.txt 
b/Documentation/networking/operstates.txt
index 355c6d8ef..8f1c4ff79 100644
--- a/Documentation/networking/operstates.txt
+++ b/Documentation/networking/operstates.txt
@@ -22,8 +22,11 @@ and changeable from userspace under certain rules.
 2. Querying from userspace
 
 Both admin and operational state can be queried via the netlink
-operation RTM_GETLINK. It is also possible to subscribe to RTMGRP_LINK
-to be notified of updates. This is important for setting from userspace.
+operation RTM_GETLINK. This is important for setting from userspace.
+It is also possible to be notified of updates to the operational state
+as long as the interface is admin up. For this, either subscribe to
+the netlink multicast group RTNLGRP_LINK, or listen for "change"
+uevents on the device.
 
 These values contain interface state:
 
@@ -102,7 +105,7 @@ complete. Corresponding functions are netif_dormant_on() to 
set the
 flag, netif_dormant_off() to clear it and netif_dormant() to query.
 
 On device allocation, networking core sets the flags equivalent to
-netif_carrier_ok() and !netif_dormant().
+!netif_carrier_ok() and netif_dormant().
 
 
 Whenever the driver CHANGES one of these flags, a workqueue event is
@@ -133,11 +136,11 @@ netif_carrier_ok() && !netif_dormant() is set by the
 driver. Afterwards, the userspace application can set IFLA_OPERSTATE
 to IF_OPER_DORMANT or IF_OPER_UP as long as the driver does not set
 netif_carrier_off() or netif_dormant_on(). Changes made by userspace
-are multicasted on the netlink group RTMGRP_LINK.
+are multicasted on the netlink group RTNLGRP_LINK.
 
 So basically a 802.1X supplicant interacts with the kernel like this:
 
--subscribe to RTMGRP_LINK
+-subscribe to RTNLGRP_LINK
 -set IFLA_LINKMODE to 1 via RTM_SETLINK
 -query RTM_GETLINK once to get initial state
 -if initial flags are not (IFF_LOWER_UP && !IFF_DORMANT), wait until
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index de1663f7d..3a59e440f 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -500,7 +500,7 @@ static void dev_watchdog_down(struct net_device *dev)
  * netif_carrier_on - set carrier
  * @dev: network device
  *
- * Device has detected that carrier.
+ * Device has detected acquisition of carrier.
  */
 void netif_carrier_on(struct net_device *dev)
 {
-- 
2.19.2



[PATCH 1/2] net: linkwatch: send change uevent on link changes

2018-12-01 Thread Jouke Witteveen
Make it easy for userspace to respond to acquisition/loss of carrier.
The uevent is picked up by udev and, on systems with systemd, the
device unit of the interface announces a configuration reload.

Signed-off-by: Jouke Witteveen 
---
I did not want to change the commit message into a systemd-howto, but
subscribing to udev events can be done through a line like
ReloadPropagatedFrom=sys-subsystem-net-devices-%i.device
in a systemd unit file.

 net/core/link_watch.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/core/link_watch.c b/net/core/link_watch.c
index 7f51efb2b..66aeb88f8 100644
--- a/net/core/link_watch.c
+++ b/net/core/link_watch.c
@@ -162,6 +162,8 @@ static void linkwatch_do_dev(struct net_device *dev)
dev_deactivate(dev);
 
netdev_state_change(dev);
+
+   kobject_uevent(>dev.kobj, KOBJ_CHANGE);
}
dev_put(dev);
 }
-- 
2.19.2



Re: consistency for statistics with XDP mode

2018-12-01 Thread Jesper Dangaard Brouer
On Fri, 30 Nov 2018 23:54:10 +
Saeed Mahameed  wrote:

> On Fri, 2018-11-30 at 15:30 -0500, Michael S. Tsirkin wrote:
> > On Fri, Nov 30, 2018 at 08:10:58PM +, Saeed Mahameed wrote:  
> > > On Thu, 2018-11-22 at 18:00 +0100, Toke Høiland-Jørgensen wrote:  
> > > > David Ahern  writes:
> > > >   
> > > > > On 11/22/18 1:26 AM, Toke Høiland-Jørgensen wrote:  
> > > > > > Saeed Mahameed  writes:
> > > > > >   
> > > > > > > > > I'd say it sounds reasonable to include XDP in the
> > > > > > > > > normal
> > > > > > > > > traffic
> > > > > > > > > counters, but having the detailed XDP-specific counters
> > > > > > > > > is
> > > > > > > > > quite
> > > > > > > > > useful
> > > > > > > > > as well... So can't we do both (for all drivers)?
> > > > > > > > >   
> > > > > > > 
> > > > > > > What are you thinking ? 
> > > > > > > reporting XDP_DROP in interface dropped counter ?
> > > > > > > and XDP_TX/REDIRECT in the TX counter ?
> > > > > > > XDP_ABORTED in the  err/drop counter ?
> > > > > > > 
> > > > > > > how about having a special XDP command in the .ndo_bpf that
> > > > > > > would query
> > > > > > > the standardized XDP stats ?  
> > > > > > the XDP-specific stats are useful to have separately as well
> > > > > > :)
> > > > > >   
> > > > > 
> > > > > I would like to see basic packets, bytes, and dropped counters
> > > > > tracked
> > > > > for Rx and Tx via the standard netdev counters for all
> > > > > devices.   
> > > 
> > > The problem of reporting XDP_DROP in the netedev drop counter is
> > > that
> > > they don't fit this counter description : "no space in linux
> > > buffers"
> > > and it will be hard for the user to determine whether these drops
> > > are
> > > coming from XDP or because no buffer is available, which will make
> > > it
> > > impossible to estimate packet rate performance without looking at
> > > ethtool stats.
> > > And reporting XDP_DROP in the netdev rx packets counter is somehow
> > > misleading.. since those packets never made it out of this
> > > driver.. 
> > > 
> > > 
> > > And reporting XDP_DROP in the netdev rx packets counter is somehow
> > > misleading.. since those packets never made it out of this driver..  
> > 
> > I think I agree. XDP needs minimal overhead - if user wants to do
> > counters then user can via maps. And in a sense XDP dropping packet
> > is much like e.g. TCP dropping packet - it is not counted
> > against the driver since it's not driver's fault.  
> 
> So we should count all XDP RX packets as successful rx packets i.e
> netdev->stats.rx_packets++; regardless of the XDP program decision ? 

Yes.

> this implies that XDP_TX packets will be counted twice once in 
> netdev->stats.rx_packets and once in netdev->stats.tx_packets

Yes, because the packet was RX'ed on the interface, and then TX'ed on
the interface.  Users expect to see these packets (ac)counted.

> I think this is the only valid option if we are going to use standard
> netdev stats for XDP use cases.

IMHO XDP_DROP should not be accounted as netdev stats drops, this is a
user installed program like tc/iptables, that can also choose to drop
packets.

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer


Re: consistency for statistics with XDP mode

2018-12-01 Thread Jesper Dangaard Brouer
On Fri, 30 Nov 2018 20:41:48 -0800
Jakub Kicinski  wrote:

> On Fri, 30 Nov 2018 13:35:53 -0700, David Ahern wrote:
> > On 11/30/18 1:30 PM, Michael S. Tsirkin wrote:  
> >  I would like to see basic packets, bytes, and dropped counters
> >  tracked
> >  for Rx and Tx via the standard netdev counters for all devices. 
> > >>
> > >> The problem of reporting XDP_DROP in the netedev drop counter is that
> > >> they don't fit this counter description : "no space in linux buffers"
> > >> and it will be hard for the user to determine whether these drops are
> > >> coming from XDP or because no buffer is available, which will make it
> > >> impossible to estimate packet rate performance without looking at
> > >> ethtool stats.
> > >> And reporting XDP_DROP in the netdev rx packets counter is somehow
> > >> misleading.. since those packets never made it out of this driver.. 
> > >>
> > >>
> > >> And reporting XDP_DROP in the netdev rx packets counter is somehow
> > >> misleading.. since those packets never made it out of this driver..
> > > 
> > > I think I agree. XDP needs minimal overhead - if user wants to do
> > > counters then user can via maps. And in a sense XDP dropping packet
> > > is much like e.g. TCP dropping packet - it is not counted
> > > against the driver since it's not driver's fault.
> > > 
> > 
> > XDP dropping a packet is completely different.
> > 
> > stats are important. packets disappearing with no counters -- standard
> > counters visible by standard tools -- is a user nightmare. If the
> > agreement is for XDP drops to be in driver level (e.g., xdp_drop) that
> > is fine since it is still retrievable by ethtool -S (existing APIs and
> > existing tools).  
> 
> I don't think that's completely fair.  Disappearing packets are a
> nightmare, but if the user installed a program which silently drops
> packets without incrementing any counter it's their own fault.  If
> cls_bpf returns STOLEN or TRAP, I don't think that's gonna get counted
> anywhere.

Yes, exactly. I think we are all agreeing.

RX packets in the driver NAPI-poll need to be counted as we have always
done in ifconfig stats.  These RX counters are incremented, regardless
of TC/netfilter drop the packet later.  Like wise XDP is a user
installed program, and a user XDP_DROP action/choice should not "hide"
this packet from the drivers RX-counter (as that IMHO could be more
confusing to the user).


> I don't think DPDK drivers maintain "just in case" statistics, either..

I agree. Maintaining counters for everything will cause performance
issues.  That said if we do choose to standardize XDP stats per action,
as most driver do maintain some ethtool counter anyhow, then we have to
make sure this doesn't hurt performance.  One simple trick is to bulk
update these counters at the end of drivers napi_pool function (like
most drivers do for the RX-counter stats).

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer


Re: [PATCH net-next,v4 05/12] flow_offload: add statistics retrieval infrastructure and use it

2018-12-01 Thread Pablo Neira Ayuso
Hi Jakub,

On Thu, Nov 29, 2018 at 12:48:22PM -0800, Jakub Kicinski wrote:
> On Thu, 29 Nov 2018 03:22:24 +0100, Pablo Neira Ayuso wrote:
> > This patch provides the flow_stats structure that acts as container for
> > tc_cls_flower_offload, then we can use to restore the statistics on the
> > existing TC actions. Hence, tcf_exts_stats_update() is not used from
> > drivers anymore.
> > 
> > Signed-off-by: Pablo Neira Ayuso 
> 
> > diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
> > index dabc819b6cc9..040c092c000a 100644
> > --- a/include/net/flow_offload.h
> > +++ b/include/net/flow_offload.h
> > @@ -179,4 +179,18 @@ static inline bool flow_rule_match_key(const struct 
> > flow_rule *rule,
> > return dissector_uses_key(rule->match.dissector, key);
> >  }
> >  
> > +struct flow_stats {
> > +   u64 pkts;
> > +   u64 bytes;
> > +   u64 lastused;
> > +};
> > +
> > +static inline void flow_stats_update(struct flow_stats *flow_stats,
> > +u64 pkts, u64 bytes, u64 lastused)
> > +{
> > +   flow_stats->pkts= pkts;
> > +   flow_stats->bytes   = bytes;
> > +   flow_stats->lastused= lastused;
> > +}
> > +
> >  #endif /* _NET_FLOW_OFFLOAD_H */
> > diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h
> > index abb035f84321..a08c06e383db 100644
> > --- a/include/net/pkt_cls.h
> > +++ b/include/net/pkt_cls.h
> > @@ -767,6 +767,7 @@ struct tc_cls_flower_offload {
> > enum tc_fl_command command;
> > unsigned long cookie;
> > struct flow_rule *rule;
> > +   struct flow_stats stats;
> > struct tcf_exts *exts;
> > u32 classid;
> >  };
> > diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
> > index 8898943b8ee6..b88cf29aff7b 100644
> > --- a/net/sched/cls_flower.c
> > +++ b/net/sched/cls_flower.c
> > @@ -432,6 +432,10 @@ static void fl_hw_update_stats(struct tcf_proto *tp, 
> > struct cls_fl_filter *f)
> >  
> > tc_setup_cb_call(block, >exts, TC_SETUP_CLSFLOWER,
> >  _flower, false);
> > +
> > +   tcf_exts_stats_update(>exts, cls_flower.stats.bytes,
> > + cls_flower.stats.pkts,
> > + cls_flower.stats.lastused);
> >  }
> >  
> >  static bool __fl_delete(struct tcf_proto *tp, struct cls_fl_filter *f,
> 
> Apart from the bug Venkat mentioned I think this patch exposes a
> potentially strange and unexpected TC-ism through to the abstracted API.
> The stats for TC store the increment in update cycle, so flow->stats
> will be equal to the diff between TC_CLSFLOWER_STATS calls.

Goal of this patch is to stop exposing tcf_exts to drivers, so it is a
preparation patch to remove a dependency. This patch introduces
infrastructure to wheelbarrow the counters back to TC, as a result we
a have centralized tcf_exts_stats_update() call and TC actions are not
exposed anymore. Ethtool does not seem to expose counters, so it does
not need this infrastructure. So you are right, the statistics
interface is very much TC specific at this stage.


[PATCH v1 net-next 14/14] octeontx2-af: Enable mkex profile

2018-12-01 Thread Jerin Jacob
From: Vamsi Attunuru 

The following set of NPC registers allow the driver to configure NPC
to generate different key value schemes to compare against packet
payload in MCAM search.

NPC_AF_INTF(0..1)_KEX_CFG
NPC_AF_KEX_LDATA(0..1)_FLAGS_CFG
NPC_AF_INTF(0..1)_LID(0..7)_LT(0..15)_LD(0..1)_CFG
NPC_AF_INTF(0..1)_LDATA(0..1)_FLAGS(0..15)_CFG

Currently, the AF driver populates these registers to
configure the default values to address the most common
use cases such as key generation for channel number + DMAC.

The secure firmware stores different configuration
value of these registers to enable different NPC use case
along with the name for the lookup.

Patch loads profile binary from secure firmware over
the exiting CGX mailbox interface and apply the profile.

AF driver shall fall back to the default configuration
in case of any errors.

The AF consumer driver can know the selected profile
on response to NPC_GET_KEX_CFG mailbox by introducing
mkex_pfl_name in the struct npc_get_kex_cfg_rsp.

Signed-off-by: Vamsi Attunuru 
Signed-off-by: Jerin Jacob 
---
 .../net/ethernet/marvell/octeontx2/af/cgx.c   |  54 +
 .../net/ethernet/marvell/octeontx2/af/cgx.h   |   1 +
 .../ethernet/marvell/octeontx2/af/cgx_fw_if.h |  12 ++
 .../net/ethernet/marvell/octeontx2/af/mbox.h  |   2 +
 .../net/ethernet/marvell/octeontx2/af/npc.h   |  18 +++
 .../net/ethernet/marvell/octeontx2/af/rvu.c   |  15 +++
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |   2 +
 .../ethernet/marvell/octeontx2/af/rvu_npc.c   | 111 +-
 8 files changed, 213 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c 
b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
index 4c94571e03eb..742f0c1f60df 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
@@ -498,6 +498,60 @@ static inline bool cgx_event_is_linkevent(u64 event)
return false;
 }
 
+static inline int cgx_fwi_get_mkex_prfl_sz(u64 *prfl_sz,
+  struct cgx *cgx)
+{
+   u64 req = 0;
+   u64 resp;
+   int err;
+
+   req = FIELD_SET(CMDREG_ID, CGX_CMD_GET_MKEX_PRFL_SIZE, req);
+   err = cgx_fwi_cmd_generic(req, , cgx, 0);
+   if (!err)
+   *prfl_sz = FIELD_GET(RESP_MKEX_PRFL_SIZE, resp);
+
+   return err;
+}
+
+static inline int cgx_fwi_get_mkex_prfl_addr(u64 *prfl_addr,
+struct cgx *cgx)
+{
+   u64 req = 0;
+   u64 resp;
+   int err;
+
+   req = FIELD_SET(CMDREG_ID, CGX_CMD_GET_MKEX_PRFL_ADDR, req);
+   err = cgx_fwi_cmd_generic(req, , cgx, 0);
+   if (!err)
+   *prfl_addr = FIELD_GET(RESP_MKEX_PRFL_ADDR, resp);
+
+   return err;
+}
+
+int cgx_get_mkex_prfl_info(u64 *addr, u64 *size)
+{
+   struct cgx *cgx_dev;
+   int err;
+
+   if (!addr || !size)
+   return -EINVAL;
+
+   cgx_dev = list_first_entry(_list, struct cgx, cgx_list);
+   if (!cgx_dev)
+   return -ENXIO;
+
+   err = cgx_fwi_get_mkex_prfl_sz(size, cgx_dev);
+   if (err)
+   return -EIO;
+
+   err = cgx_fwi_get_mkex_prfl_addr(addr, cgx_dev);
+   if (err)
+   return -EIO;
+
+   return 0;
+}
+EXPORT_SYMBOL(cgx_get_mkex_prfl_info);
+
 static irqreturn_t cgx_fwi_event_handler(int irq, void *data)
 {
struct lmac *lmac = data;
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.h 
b/drivers/net/ethernet/marvell/octeontx2/af/cgx.h
index 8c2be8493321..206dc5dc1df8 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.h
@@ -111,4 +111,5 @@ int cgx_lmac_internal_loopback(void *cgxd, int lmac_id, 
bool enable);
 int cgx_get_link_info(void *cgxd, int lmac_id,
  struct cgx_link_user_info *linfo);
 int cgx_lmac_linkup_start(void *cgxd);
+int cgx_get_mkex_prfl_info(u64 *addr, u64 *size);
 #endif /* CGX_H */
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx_fw_if.h 
b/drivers/net/ethernet/marvell/octeontx2/af/cgx_fw_if.h
index 2d9fe51c6616..fb3ba4968a9b 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/cgx_fw_if.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx_fw_if.h
@@ -78,6 +78,8 @@ enum cgx_cmd_id {
CGX_CMD_LINK_STATE_CHANGE,
CGX_CMD_MODE_CHANGE,/* hot plug support */
CGX_CMD_INTF_SHUTDOWN,
+   CGX_CMD_GET_MKEX_PRFL_SIZE,
+   CGX_CMD_GET_MKEX_PRFL_ADDR
 };
 
 /* async event ids */
@@ -137,6 +139,16 @@ enum cgx_cmd_own {
  */
 #define RESP_MAC_ADDR  GENMASK_ULL(56, 9)
 
+/* Response to cmd ID as CGX_CMD_GET_MKEX_PRFL_SIZE with cmd status as
+ * CGX_STAT_SUCCESS
+ */
+#define RESP_MKEX_PRFL_SIZEGENMASK_ULL(63, 9)
+
+/* Response to cmd ID as CGX_CMD_GET_MKEX_PRFL_ADDR with cmd status as
+ * CGX_STAT_SUCCESS
+ */
+#define RESP_MKEX_PRFL_ADDRGENMASK_ULL(63, 9)
+
 /* Response to cmd ID - 

[PATCH v1 net-next 13/14] octeontx2-af: Add LSO format configuration mailbox

2018-12-01 Thread Jerin Jacob
From: Nithin Dabilpuram 

NIX_AF_LSO_FORMAT(0..31)_FIELD(0..7) register enables an SW defined
means to define LSO packet modification formats.

0..31 works as an index to choose the algorithm, On success, the mailbox
returns the index to the client of chosen LSO algorithm selection.
This index will be used in configuring the transmit descriptors.

Add mailbox interface to dynamically reserve and configure LSO format.

This commit also fixes 'sizem1' for NIX_LSOALG_TCP_FLAGS
to '1' i.e 2 Bytes.

Signed-off-by: Nithin Dabilpuram 
Signed-off-by: Sunil Goutham 
Signed-off-by: Jerin Jacob 
---
 .../net/ethernet/marvell/octeontx2/af/mbox.h  | 16 +
 .../net/ethernet/marvell/octeontx2/af/rvu.h   | 10 ++-
 .../ethernet/marvell/octeontx2/af/rvu_nix.c   | 72 +--
 3 files changed, 91 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h 
b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
index a4c391fe5eb2..01a96a4b0eab 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
@@ -204,6 +204,9 @@ M(NIX_MARK_FORMAT_CFG,  0x800f, nix_mark_format_cfg,
\
 nix_mark_format_cfg,   \
 nix_mark_format_cfg_rsp)   \
 M(NIX_SET_RX_CFG,  0x8010, nix_set_rx_cfg, nix_rx_cfg, msg_rsp)\
+M(NIX_LSO_FORMAT_CFG,  0x8011, nix_lso_format_cfg, \
+nix_lso_format_cfg,\
+nix_lso_format_cfg_rsp)\
 M(NIX_RXVLAN_ALLOC,0x8012, nix_rxvlan_alloc, msg_req, msg_rsp)
 
 /* Messages initiated by AF (range 0xC00 - 0xDFF) */
@@ -421,6 +424,7 @@ enum nix_af_status {
NIX_AF_ERR_RSS_NOSPC_FIELD  = -415,
NIX_AF_ERR_RSS_NOSPC_ALGO   = -416,
NIX_AF_ERR_MARK_CFG_FAIL= -417,
+   NIX_AF_ERR_LSO_CFG_FAIL = -418,
NIX_AF_INVAL_NPA_PF_FUNC= -419,
NIX_AF_INVAL_SSO_PF_FUNC= -420,
 };
@@ -628,6 +632,18 @@ struct nix_frs_cfg {
u16 minlen;
 };
 
+struct nix_lso_format_cfg {
+   struct mbox_msghdr hdr;
+   u64 field_mask;
+#define NIX_LSO_FIELD_MAX  8
+   u64 fields[NIX_LSO_FIELD_MAX];
+};
+
+struct nix_lso_format_cfg_rsp {
+   struct mbox_msghdr hdr;
+   u8 lso_format_idx;
+};
+
 /* NPC mbox message structs */
 
 #define NPC_MCAM_ENTRY_INVALID 0x
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
index a890d4ff867a..6a26e5f51429 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
@@ -180,11 +180,17 @@ struct nix_flowkey {
int in_use;
 };
 
+struct nix_lso {
+   u8 total;
+   u8 in_use;
+};
+
 struct nix_hw {
struct nix_txsch txsch[NIX_TXSCH_LVL_CNT]; /* Tx schedulers */
struct nix_mcast mcast;
struct nix_flowkey flowkey;
struct nix_mark_format mark_format;
+   struct nix_lso lso;
 };
 
 struct rvu_hwinfo {
@@ -435,7 +441,9 @@ int rvu_mbox_handler_nix_mark_format_cfg(struct rvu *rvu,
 struct nix_mark_format_cfg_rsp *rsp);
 int rvu_mbox_handler_nix_set_rx_cfg(struct rvu *rvu, struct nix_rx_cfg *req,
struct msg_rsp *rsp);
-
+int rvu_mbox_handler_nix_lso_format_cfg(struct rvu *rvu,
+   struct nix_lso_format_cfg *req,
+   struct nix_lso_format_cfg_rsp *rsp);
 
 /* NPC APIs */
 int rvu_npc_init(struct rvu *rvu);
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index f80f39b046d8..e27dc24b7d2a 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -298,17 +298,21 @@ static void nix_setup_lso_tso_l4(struct rvu *rvu, int 
blkaddr,
/* TCP's flags field */
field.layer = NIX_TXLAYER_OL4;
field.offset = 12;
-   field.sizem1 = 0; /* not needed */
+   field.sizem1 = 1; /* 2 bytes */
field.alg = NIX_LSOALG_TCP_FLAGS;
rvu_write64(rvu, blkaddr,
NIX_AF_LSO_FORMATX_FIELDX(format, (*fidx)++),
*(u64 *));
 }
 
-static void nix_setup_lso(struct rvu *rvu, int blkaddr)
+static void nix_setup_lso(struct rvu *rvu, struct nix_hw *nix_hw, int blkaddr)
 {
u64 cfg, idx, fidx = 0;
 
+   /* Get max HW supported format indices */
+   cfg = (rvu_read64(rvu, blkaddr, NIX_AF_CONST1) >> 48) & 0xFF;
+   nix_hw->lso.total = cfg;
+
/* Enable LSO */
cfg = rvu_read64(rvu, blkaddr, NIX_AF_LSO_CFG);
/* For TSO, set first and middle segment flags to
@@ -318,7 +322,10 @@ static void nix_setup_lso(struct rvu *rvu, int blkaddr)
cfg |= (0xFFF2ULL << 32) | (0xFFF2ULL << 

[PATCH v1 net-next 11/14] octeontx2-af: Configure VLAN TPIDs

2018-12-01 Thread Jerin Jacob
From: Nithin Dabilpuram 

Setup TPID's for vlan0 and vlan1 for Tx VLAN insertion offloads.

Signed-off-by: Nithin Dabilpuram 
Signed-off-by: Jerin Jacob 
---
 drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index 066f2fc80c1c..5baa427952bb 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -865,6 +865,13 @@ int rvu_mbox_handler_nix_lf_alloc(struct rvu *rvu,
(u64)pfvf->nix_qints_ctx->iova);
rvu_write64(rvu, blkaddr, NIX_AF_LFX_QINTS_CFG(nixlf), BIT_ULL(36));
 
+   /* Setup VLANX TPID's.
+* Use VLAN1 for 802.1Q
+* and VLAN0 for 802.1AD.
+*/
+   cfg = (0x8100ULL << 16) | 0x88A8ULL;
+   rvu_write64(rvu, blkaddr, NIX_AF_LFX_TX_CFG(nixlf), cfg);
+
/* Enable LMTST for this NIX LF */
rvu_write64(rvu, blkaddr, NIX_AF_LFX_TX_CFG2(nixlf), BIT_ULL(0));
 
-- 
2.19.2



[PATCH v1 net-next 12/14] octeontx2-af: Add L3 and L4 packet verification mailbox

2018-12-01 Thread Jerin Jacob
From: Vidhya Raman 

Adds mailbox support for L4 checksum verification
and L3 and L4 length verification configuration.

Signed-off-by: Vidhya Raman 
Signed-off-by: Jerin Jacob 
---
 .../net/ethernet/marvell/octeontx2/af/mbox.h  | 10 +
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |  3 ++
 .../ethernet/marvell/octeontx2/af/rvu_nix.c   | 42 +++
 3 files changed, 55 insertions(+)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h 
b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
index 723586740de6..a4c391fe5eb2 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
@@ -203,6 +203,7 @@ M(NIX_LF_STOP_RX,   0x800e, nix_lf_stop_rx, msg_req, 
msg_rsp)   \
 M(NIX_MARK_FORMAT_CFG, 0x800f, nix_mark_format_cfg,\
 nix_mark_format_cfg,   \
 nix_mark_format_cfg_rsp)   \
+M(NIX_SET_RX_CFG,  0x8010, nix_set_rx_cfg, nix_rx_cfg, msg_rsp)\
 M(NIX_RXVLAN_ALLOC,0x8012, nix_rxvlan_alloc, msg_req, msg_rsp)
 
 /* Messages initiated by AF (range 0xC00 - 0xDFF) */
@@ -609,6 +610,15 @@ struct nix_rx_mode {
u16 mode;
 };
 
+struct nix_rx_cfg {
+   struct mbox_msghdr hdr;
+#define NIX_RX_OL3_VERIFY   BIT(0)
+#define NIX_RX_OL4_VERIFY   BIT(1)
+   u8 len_verify; /* Outer L3/L4 len check */
+#define NIX_RX_CSUM_OL4_VERIFY  BIT(0)
+   u8 csum_verify; /* Outer L4 checksum verification */
+};
+
 struct nix_frs_cfg {
struct mbox_msghdr hdr;
u8  update_smq;/* Update SMQ's min/max lens */
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
index e976789e8a8e..a890d4ff867a 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
@@ -433,6 +433,9 @@ int rvu_mbox_handler_nix_lf_stop_rx(struct rvu *rvu, struct 
msg_req *req,
 int rvu_mbox_handler_nix_mark_format_cfg(struct rvu *rvu,
 struct nix_mark_format_cfg  *req,
 struct nix_mark_format_cfg_rsp *rsp);
+int rvu_mbox_handler_nix_set_rx_cfg(struct rvu *rvu, struct nix_rx_cfg *req,
+   struct msg_rsp *rsp);
+
 
 /* NPC APIs */
 int rvu_npc_init(struct rvu *rvu);
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index 5baa427952bb..f80f39b046d8 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -2503,6 +2503,48 @@ int rvu_mbox_handler_nix_rxvlan_alloc(struct rvu *rvu, 
struct msg_req *req,
return err;
 }
 
+int rvu_mbox_handler_nix_set_rx_cfg(struct rvu *rvu, struct nix_rx_cfg *req,
+   struct msg_rsp *rsp)
+{
+   struct rvu_hwinfo *hw = rvu->hw;
+   u16 pcifunc = req->hdr.pcifunc;
+   struct rvu_block *block;
+   struct rvu_pfvf *pfvf;
+   int nixlf, blkaddr;
+   u64 cfg;
+
+   pfvf = rvu_get_pfvf(rvu, pcifunc);
+   blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, pcifunc);
+   if (!pfvf->nixlf || blkaddr < 0)
+   return NIX_AF_ERR_AF_LF_INVALID;
+
+   block = >block[blkaddr];
+   nixlf = rvu_get_lf(rvu, block, pcifunc, 0);
+   if (nixlf < 0)
+   return NIX_AF_ERR_AF_LF_INVALID;
+
+   cfg = rvu_read64(rvu, blkaddr, NIX_AF_LFX_RX_CFG(nixlf));
+   /* Set the interface configuration */
+   if (req->len_verify & BIT(0))
+   cfg |= BIT_ULL(41);
+   else
+   cfg &= ~BIT_ULL(41);
+
+   if (req->len_verify & BIT(1))
+   cfg |= BIT_ULL(40);
+   else
+   cfg &= ~BIT_ULL(40);
+
+   if (req->csum_verify & BIT(0))
+   cfg |= BIT_ULL(37);
+   else
+   cfg &= ~BIT_ULL(37);
+
+   rvu_write64(rvu, blkaddr, NIX_AF_LFX_RX_CFG(nixlf), cfg);
+
+   return 0;
+}
+
 static void nix_link_config(struct rvu *rvu, int blkaddr)
 {
struct rvu_hwinfo *hw = rvu->hw;
-- 
2.19.2



[PATCH v1 net-next 08/14] octeontx2-af: Define all NIX_AF_RX_DEF_* registers

2018-12-01 Thread Jerin Jacob
From: Jerin Jacob 

In order to support all NIX specific valid length errors and
checksum errors on Rx, Update all NIX_AF_RX_DEF_* registers.

Also sorted all registers in HRM definition order.

Signed-off-by: Jerin Jacob 
---
 .../ethernet/marvell/octeontx2/af/rvu_nix.c   | 25 +++
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index 4c73a9c661e8..4b5b040941ee 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -2592,18 +2592,33 @@ int rvu_nix_init(struct rvu *rvu)
if (err)
return err;
 
-   /* Config Outer L2, IP, TCP and UDP's NPC layer info.
+   /* Config Outer/Inner L2, IP, TCP, UDP and SCTP NPC layer info.
 * This helps HW protocol checker to identify headers
 * and validate length and checksums.
 */
rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_OL2,
(NPC_LID_LA << 8) | (NPC_LT_LA_ETHER << 4) | 0x0F);
-   rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_OUDP,
-   (NPC_LID_LD << 8) | (NPC_LT_LD_UDP << 4) | 0x0F);
-   rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_OTCP,
-   (NPC_LID_LD << 8) | (NPC_LT_LD_TCP << 4) | 0x0F);
rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_OIP4,
(NPC_LID_LC << 8) | (NPC_LT_LC_IP << 4) | 0x0F);
+   rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_IIP4,
+   (NPC_LID_LF << 8) | (NPC_LT_LF_TU_IP << 4) | 0x0F);
+   rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_OIP6,
+   (NPC_LID_LC << 8) | (NPC_LT_LC_IP6 << 4) | 0x0F);
+   rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_IIP6,
+   (NPC_LID_LF << 8) | (NPC_LT_LF_TU_IP6 << 4) | 0x0F);
+   rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_OTCP,
+   (NPC_LID_LD << 8) | (NPC_LT_LD_TCP << 4) | 0x0F);
+   rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_ITCP,
+   (NPC_LID_LG << 8) | (NPC_LT_LG_TU_TCP << 4) | 0x0F);
+   rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_OUDP,
+   (NPC_LID_LD << 8) | (NPC_LT_LD_UDP << 4) | 0x0F);
+   rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_IUDP,
+   (NPC_LID_LG << 8) | (NPC_LT_LG_TU_UDP << 4) | 0x0F);
+   rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_OSCTP,
+   (NPC_LID_LD << 8) | (NPC_LT_LD_SCTP << 4) | 0x0F);
+   rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_ISCTP,
+   (NPC_LID_LG << 8) | (NPC_LT_LG_TU_SCTP << 4) |
+   0x0F);
 
err = nix_rx_flowkey_alg_cfg(rvu, blkaddr);
if (err)
-- 
2.19.2



[PATCH v1 net-next 10/14] octeontx2-af: Add support for Tx packet marking

2018-12-01 Thread Jerin Jacob
From: Krzysztof Kanas 

NIX_AF_MARK_FORMAT(0..127)_CTL register enables an SW defined
means to mark/insert various data in the packet based on
final packet color from traffic shaping HW.

0..127 works as an index to choose the algorithm. On success,
the mailbox returns the index to the client.

Add NIX_MARK_FORMAT_CFG mailbox which reserves mark format based on
tuple (offset, y_mask, y_val, r_mask, r_val)

If the tuple is requested again for mark format that was already
reserved, then it will be reused. If not it will reserve a new entry
if space is available.

Also on AF init commonly used marker format such as VLAN DEI, IPv4
ECN, IPv4 DSCP are reserved for AF consumers.

Signed-off-by: Krzysztof Kanas 
Signed-off-by: Jerin Jacob 
---
 .../net/ethernet/marvell/octeontx2/af/mbox.h  |  18 +++
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |  12 ++
 .../ethernet/marvell/octeontx2/af/rvu_nix.c   | 103 ++
 3 files changed, 133 insertions(+)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h 
b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
index 66aa202a3fed..723586740de6 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
@@ -200,6 +200,9 @@ M(NIX_SET_RX_MODE,  0x800b, nix_set_rx_mode, nix_rx_mode, 
msg_rsp)  \
 M(NIX_SET_HW_FRS,  0x800c, nix_set_hw_frs, nix_frs_cfg, msg_rsp)   \
 M(NIX_LF_START_RX, 0x800d, nix_lf_start_rx, msg_req, msg_rsp)  \
 M(NIX_LF_STOP_RX,  0x800e, nix_lf_stop_rx, msg_req, msg_rsp)   \
+M(NIX_MARK_FORMAT_CFG, 0x800f, nix_mark_format_cfg,\
+nix_mark_format_cfg,   \
+nix_mark_format_cfg_rsp)   \
 M(NIX_RXVLAN_ALLOC,0x8012, nix_rxvlan_alloc, msg_req, msg_rsp)
 
 /* Messages initiated by AF (range 0xC00 - 0xDFF) */
@@ -416,6 +419,7 @@ enum nix_af_status {
NIX_AF_ERR_LF_RESET = -414,
NIX_AF_ERR_RSS_NOSPC_FIELD  = -415,
NIX_AF_ERR_RSS_NOSPC_ALGO   = -416,
+   NIX_AF_ERR_MARK_CFG_FAIL= -417,
NIX_AF_INVAL_NPA_PF_FUNC= -419,
NIX_AF_INVAL_SSO_PF_FUNC= -420,
 };
@@ -583,6 +587,20 @@ struct nix_set_mac_addr {
u8 mac_addr[ETH_ALEN]; /* MAC address to be set for this pcifunc */
 };
 
+struct nix_mark_format_cfg {
+   struct mbox_msghdr hdr;
+   u8 offset;
+   u8 y_mask;
+   u8 y_val;
+   u8 r_mask;
+   u8 r_val;
+};
+
+struct nix_mark_format_cfg_rsp {
+   struct mbox_msghdr hdr;
+   u8 mark_format_idx;
+};
+
 struct nix_rx_mode {
struct mbox_msghdr hdr;
 #define NIX_RX_MODE_UCAST  BIT(0)
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
index da9faaf856cb..e976789e8a8e 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
@@ -163,6 +163,12 @@ struct nix_txsch {
u32  *pfvf_map;
 };
 
+struct nix_mark_format {
+   u8 total;
+   u8 in_use;
+   u32 *cfg;
+};
+
 struct npc_pkind {
struct rsrc_bmap rsrc;
u32 *pfchan_map;
@@ -178,6 +184,7 @@ struct nix_hw {
struct nix_txsch txsch[NIX_TXSCH_LVL_CNT]; /* Tx schedulers */
struct nix_mcast mcast;
struct nix_flowkey flowkey;
+   struct nix_mark_format mark_format;
 };
 
 struct rvu_hwinfo {
@@ -377,6 +384,8 @@ int rvu_mbox_handler_npa_lf_free(struct rvu *rvu, struct 
msg_req *req,
 /* NIX APIs */
 bool is_nixlf_attached(struct rvu *rvu, u16 pcifunc);
 int rvu_nix_init(struct rvu *rvu);
+int rvu_nix_reserve_mark_format(struct rvu *rvu, struct nix_hw *nix_hw,
+   int blkaddr, u32 cfg);
 void rvu_nix_freemem(struct rvu *rvu);
 int rvu_get_nixlf_count(struct rvu *rvu);
 void rvu_nix_lf_teardown(struct rvu *rvu, u16 pcifunc, int blkaddr, int npalf);
@@ -421,6 +430,9 @@ int rvu_mbox_handler_nix_lf_start_rx(struct rvu *rvu, 
struct msg_req *req,
 struct msg_rsp *rsp);
 int rvu_mbox_handler_nix_lf_stop_rx(struct rvu *rvu, struct msg_req *req,
struct msg_rsp *rsp);
+int rvu_mbox_handler_nix_mark_format_cfg(struct rvu *rvu,
+struct nix_mark_format_cfg  *req,
+struct nix_mark_format_cfg_rsp *rsp);
 
 /* NPC APIs */
 int rvu_npc_init(struct rvu *rvu);
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index 4b5b040941ee..066f2fc80c1c 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -43,6 +43,19 @@ enum mc_buf_cnt {
MC_BUF_CNT_2048,
 };
 
+enum nix_makr_fmt_indexes {
+   NIX_MARK_CFG_IP_DSCP_RED,
+   NIX_MARK_CFG_IP_DSCP_YELLOW,
+   NIX_MARK_CFG_IP_DSCP_YELLOW_RED,
+   NIX_MARK_CFG_IP_ECN_RED,
+   

[PATCH v1 net-next 06/14] octeontx2-af: Allow freeing single TLx Tx schedule queue

2018-12-01 Thread Jerin Jacob
From: Nithin Dabilpuram 

The default behavior was to free all the TLx Tx schedule
queues. This patch adds support for freeing a single Tx
schedule queue if TXSCHQ_FREE_ALL flag is not set.

Signed-off-by: Krzysztof Kanas 
Signed-off-by: Nithin Dabilpuram 
Signed-off-by: Jerin Jacob 
---
 .../ethernet/marvell/octeontx2/af/rvu_nix.c   | 72 ++-
 1 file changed, 71 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index 90779cff1463..4c73a9c661e8 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -1255,11 +1255,81 @@ static int nix_txschq_free(struct rvu *rvu, u16 pcifunc)
return 0;
 }
 
+static int nix_txschq_free_one(struct rvu *rvu,
+  struct nix_txsch_free_req *req)
+{
+   int lvl, schq, nixlf, blkaddr, rc;
+   struct rvu_hwinfo *hw = rvu->hw;
+   u16 pcifunc = req->hdr.pcifunc;
+   struct nix_txsch *txsch;
+   struct nix_hw *nix_hw;
+   u32 *pfvf_map;
+   u64 cfg;
+
+   blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, pcifunc);
+   if (blkaddr < 0)
+   return NIX_AF_ERR_AF_LF_INVALID;
+
+   nix_hw = get_nix_hw(rvu->hw, blkaddr);
+   if (!nix_hw)
+   return -EINVAL;
+
+   nixlf = rvu_get_lf(rvu, >block[blkaddr], pcifunc, 0);
+   if (nixlf < 0)
+   return NIX_AF_ERR_AF_LF_INVALID;
+
+   lvl = req->schq_lvl;
+   schq = req->schq;
+   txsch = _hw->txsch[lvl];
+
+   /* Don't allow freeing TL1 */
+   if (lvl > NIX_TXSCH_LVL_TL2 ||
+   schq >= txsch->schq.max)
+   goto err;
+
+   pfvf_map = txsch->pfvf_map;
+   mutex_lock(>rsrc_lock);
+
+   if (TXSCH_MAP_FUNC(pfvf_map[schq]) != pcifunc) {
+   mutex_unlock(>rsrc_lock);
+   goto err;
+   }
+
+   /* Flush if it is a SMQ. Onus of disabling
+* TL2/3 queue links before SMQ flush is on user
+*/
+   if (lvl == NIX_TXSCH_LVL_SMQ) {
+   cfg = rvu_read64(rvu, blkaddr, NIX_AF_SMQX_CFG(schq));
+   /* Do SMQ flush and set enqueue xoff */
+   cfg |= BIT_ULL(50) | BIT_ULL(49);
+   rvu_write64(rvu, blkaddr, NIX_AF_SMQX_CFG(schq), cfg);
+
+   /* Wait for flush to complete */
+   rc = rvu_poll_reg(rvu, blkaddr,
+ NIX_AF_SMQX_CFG(schq), BIT_ULL(49), true);
+   if (rc) {
+   dev_err(rvu->dev,
+   "NIXLF%d: SMQ%d flush failed\n", nixlf, schq);
+   }
+   }
+
+   /* Free the resource */
+   rvu_free_rsrc(>schq, schq);
+   txsch->pfvf_map[schq] = 0;
+   mutex_unlock(>rsrc_lock);
+   return 0;
+err:
+   return NIX_AF_ERR_TLX_INVALID;
+}
+
 int rvu_mbox_handler_nix_txsch_free(struct rvu *rvu,
struct nix_txsch_free_req *req,
struct msg_rsp *rsp)
 {
-   return nix_txschq_free(rvu, req->hdr.pcifunc);
+   if (req->flags & TXSCHQ_FREE_ALL)
+   return nix_txschq_free(rvu, req->hdr.pcifunc);
+   else
+   return nix_txschq_free_one(rvu, req);
 }
 
 static bool is_txschq_config_valid(struct rvu *rvu, u16 pcifunc, int blkaddr,
-- 
2.19.2



[PATCH v1 net-next 09/14] octeontx2-af: Enable RSS with promiscuous mode

2018-12-01 Thread Jerin Jacob
From: Vamsi Attunuru 

This patch adds support for enabling RSS in promiscuous mode
if RSS is already requested by the AF client.

Signed-off-by: Vamsi Attunuru 
Signed-off-by: Jerin Jacob 
---
 .../ethernet/marvell/octeontx2/af/rvu_npc.c   | 35 ---
 1 file changed, 31 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
index c203d3fddde9..bf81031f0fdd 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
@@ -368,9 +368,9 @@ void rvu_npc_install_promisc_entry(struct rvu *rvu, u16 
pcifunc,
   int nixlf, u64 chan, bool allmulti)
 {
struct npc_mcam *mcam = >hw->mcam;
+   int blkaddr, ucast_idx, index, kwi;
struct mcam_entry entry = { {0} };
struct nix_rx_action action = { };
-   int blkaddr, index, kwi;
 
/* Only PF or AF VF can add a promiscuous entry */
if ((pcifunc & RVU_PFVF_FUNC_MASK) && !is_afvf(pcifunc))
@@ -392,9 +392,21 @@ void rvu_npc_install_promisc_entry(struct rvu *rvu, u16 
pcifunc,
entry.kw_mask[kwi] = BIT_ULL(40);
}
 
-   *(u64 *) = 0x00;
-   action.op = NIX_RX_ACTIONOP_UCAST;
-   action.pf_func = pcifunc;
+   ucast_idx = npc_get_nixlf_mcam_index(mcam, pcifunc,
+nixlf, NIXLF_UCAST_ENTRY);
+
+   /* If the corresponding PF's ucast action is RSS,
+* use the same action for promisc also
+*/
+   if (is_mcam_entry_enabled(rvu, mcam, blkaddr, ucast_idx))
+   *(u64 *) = npc_get_mcam_action(rvu, mcam,
+   blkaddr, ucast_idx);
+
+   if (action.op != NIX_RX_ACTIONOP_RSS) {
+   *(u64 *) = 0x00;
+   action.op = NIX_RX_ACTIONOP_UCAST;
+   action.pf_func = pcifunc;
+   }
 
entry.action = *(u64 *)
npc_config_mcam_entry(rvu, mcam, blkaddr, index,
@@ -539,6 +551,21 @@ void rvu_npc_update_flowkey_alg_idx(struct rvu *rvu, u16 
pcifunc, int nixlf,
rvu_write64(rvu, blkaddr,
NPC_AF_MCAMEX_BANKX_ACTION(index, bank), *(u64 *));
 
+   index = npc_get_nixlf_mcam_index(mcam, pcifunc,
+nixlf, NIXLF_PROMISC_ENTRY);
+
+   /* If PF's promiscuous entry is enabled,
+* Set RSS action for that entry as well
+*/
+   if (is_mcam_entry_enabled(rvu, mcam, blkaddr, index)) {
+   bank = npc_get_bank(mcam, index);
+   index &= (mcam->banksize - 1);
+
+   rvu_write64(rvu, blkaddr,
+   NPC_AF_MCAMEX_BANKX_ACTION(index, bank),
+   *(u64 *));
+   }
+
rvu_npc_update_rxvlan(rvu, pcifunc, nixlf);
 }
 
-- 
2.19.2



[PATCH v1 net-next 03/14] octeontx2-af: Add support for dynamic flow cfg to RSS field generation

2018-12-01 Thread Jerin Jacob
From: Jerin Jacob 

Introduce state-based algorithm to convert the flow_key value
to RSS algo field used by NIX_AF_RX_FLOW_KEY_ALGX_FIELDX register.

The outer `for loop` goes over _all_ protocol field and the following
variables depict the state machine forward progress logic.

a) keyoff_marker - Enabled when hash byte length needs to be accounted
in field->key_offset update.
b) field_marker - Enabled when a new field needs to be selected.
c) group_member - Enabled when a protocol is part of a group.

This would remove the existing hard coding and enable to add
new protocol support seamlessly.

Signed-off-by: Jerin Jacob 
Signed-off-by: Nithin Dabilpuram 
---
 .../net/ethernet/marvell/octeontx2/af/mbox.h  |   1 +
 .../ethernet/marvell/octeontx2/af/rvu_nix.c   | 112 +-
 2 files changed, 86 insertions(+), 27 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h 
b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
index 4cce31fb13ab..1e129112cc51 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
@@ -414,6 +414,7 @@ enum nix_af_status {
NIX_AF_INVAL_TXSCHQ_CFG = -412,
NIX_AF_SMQ_FLUSH_FAILED = -413,
NIX_AF_ERR_LF_RESET = -414,
+   NIX_AF_ERR_RSS_NOSPC_FIELD  = -415,
NIX_AF_INVAL_NPA_PF_FUNC= -419,
NIX_AF_INVAL_SSO_PF_FUNC= -420,
 };
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index 76fec9928ab7..5b7a0a04b529 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -1647,80 +1647,138 @@ int rvu_mbox_handler_nix_rss_flowkey_cfg(struct rvu 
*rvu,
return 0;
 }
 
-static void set_flowkey_fields(struct nix_rx_flowkey_alg *alg, u32 flow_cfg)
+static int set_flowkey_fields(struct nix_rx_flowkey_alg *alg, u32 flow_cfg)
 {
-   struct nix_rx_flowkey_alg *field = NULL;
-   int idx, key_type;
+   int idx, nr_field, key_off, field_marker, keyoff_marker;
+   int max_key_off, max_bit_pos, group_member;
+   struct nix_rx_flowkey_alg *field;
+   struct nix_rx_flowkey_alg tmp;
+   u32 key_type, valid_key;
 
if (!alg)
-   return;
+   return -EINVAL;
 
-   /* FIELD0: IPv4
-* FIELD1: IPv6
-* FIELD2: TCP/UDP/SCTP/ALL
-* FIELD3: Unused
-* FIELD4: Unused
-*
-* Each of the 32 possible flow key algorithm definitions should
+#define FIELDS_PER_ALG  5
+#define MAX_KEY_OFF40
+   /* Clear all fields */
+   memset(alg, 0, sizeof(uint64_t) * FIELDS_PER_ALG);
+
+   /* Each of the 32 possible flow key algorithm definitions should
 * fall into above incremental config (except ALG0). Otherwise a
 * single NPC MCAM entry is not sufficient for supporting RSS.
 *
 * If a different definition or combination needed then NPC MCAM
 * has to be programmed to filter such pkts and it's action should
 * point to this definition to calculate flowtag or hash.
+*
+* The `for loop` goes over _all_ protocol field and the following
+* variables depicts the state machine forward progress logic.
+*
+* keyoff_marker - Enabled when hash byte length needs to be accounted
+* in field->key_offset update.
+* field_marker - Enabled when a new field needs to be selected.
+* group_member - Enabled when protocol is part of a group.
 */
-   for (idx = 0; idx < 32; idx++) {
-   key_type = flow_cfg & BIT_ULL(idx);
-   if (!key_type)
-   continue;
+
+   keyoff_marker = 0; max_key_off = 0; group_member = 0;
+   nr_field = 0; key_off = 0; field_marker = 1;
+   field =  max_bit_pos = fls(flow_cfg);
+   for (idx = 0;
+idx < max_bit_pos && nr_field < FIELDS_PER_ALG &&
+key_off < MAX_KEY_OFF; idx++) {
+   key_type = BIT(idx);
+   valid_key = flow_cfg & key_type;
+   /* Found a field marker, reset the field values */
+   if (field_marker)
+   memset(, 0, sizeof(tmp));
+
switch (key_type) {
case FLOW_KEY_TYPE_PORT:
-   field = [0];
field->sel_chan = true;
/* This should be set to 1, when SEL_CHAN is set */
field->bytesm1 = 1;
+   field_marker = true;
+   keyoff_marker = true;
break;
case FLOW_KEY_TYPE_IPV4:
-   field = [0];
field->lid = NPC_LID_LC;
field->ltype_match = NPC_LT_LC_IP;
field->hdr_offset = 12; /* SIP offset */
field->bytesm1 = 7; /* SIP + DIP, 

[PATCH v1 net-next 07/14] octeontx2-af: Enable inner IPv4 checksum and its error code

2018-12-01 Thread Jerin Jacob
From: Jerin Jacob 

This patch enables the inner IPv4 checksum and
defines the error code for Rx inner and outer checksum errors.
Setting ERRCODE as 1 so that CQE descriptor can be embedded
valid checksum error code and the driver can interpret
checksum error as ERRLEV = LID + 1 and ERRCODE = 1.

Signed-off-by: Jerin Jacob 
---
 drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
index ee2600d93d54..c203d3fddde9 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
@@ -1008,13 +1008,20 @@ int rvu_npc_init(struct rvu *rvu)
rvu_write64(rvu, blkaddr, NPC_AF_PCK_DEF_OIP4,
(NPC_LID_LC << 8) | (NPC_LT_LC_IP << 4) | 0x0F);
 
+   /* Config Inner IPV4 NPC layer info */
+   rvu_write64(rvu, blkaddr, NPC_AF_PCK_DEF_IIP4,
+   (NPC_LID_LF << 8) | (NPC_LT_LF_TU_IP << 4) | 0x0F);
+
/* Enable below for Rx pkts.
 * - Outer IPv4 header checksum validation.
 * - Detect outer L2 broadcast address and set NPC_RESULT_S[L2M].
+* - Inner IPv4 header checksum validation.
+* - Set non zero checksum error code value
 */
rvu_write64(rvu, blkaddr, NPC_AF_PCK_CFG,
rvu_read64(rvu, blkaddr, NPC_AF_PCK_CFG) |
-   BIT_ULL(6) | BIT_ULL(2));
+   BIT_ULL(32) | BIT_ULL(24) | BIT_ULL(6) |
+   BIT_ULL(2) | BIT_ULL(1));
 
/* Set RX and TX side MCAM search key size.
 * LA..LD (ltype only) + Channel
-- 
2.19.2



[PATCH v1 net-next 05/14] octeontx2-af: Restrict TL1 allocation and configuration

2018-12-01 Thread Jerin Jacob
From: Nithin Dabilpuram 

TL1 is the root node in the scheduling hierarchy and
it is a global resource with a limited number.

This patch introduces restriction and validation on
the allocation of the TL1 nodes for the effective resource
sharing across the AF consumers.

- Limit TL1 allocation to 2 per lmac.
  One could be for the normal link and one for IEEE802.3br
  express link (Express Send DMA).
  Effectively all the VF's of an RVU PF(lmac) share the two TL1 schqs.
- TL1 cannot be freed once allocated.
- Allow VF's to only apply default config to TL1 if not
  already applied. PF's can always overwrite the TL1 config.
- Consider NIX_AQ_INSTOP_WRITE while validating txschq
  when sq.ena is set.

Signed-off-by: Krzysztof Kanas 
Signed-off-by: Nithin Dabilpuram 
Signed-off-by: Jerin Jacob 
---
 .../ethernet/marvell/octeontx2/af/common.h|   3 +
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |   6 +-
 .../ethernet/marvell/octeontx2/af/rvu_nix.c   | 230 --
 3 files changed, 221 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/common.h 
b/drivers/net/ethernet/marvell/octeontx2/af/common.h
index 72ad04eb8769..ec50a21c5aaf 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/common.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/common.h
@@ -143,6 +143,9 @@ enum nix_scheduler {
NIX_TXSCH_LVL_CNT = 0x5,
 };
 
+#define TXSCH_TL1_DFLT_RR_QTM  ((1 << 24) - 1)
+#define TXSCH_TL1_DFLT_RR_PRIO (0x1ull)
+
 /* Min/Max packet sizes, excluding FCS */
 #defineNIC_HW_MIN_FRS  40
 #defineNIC_HW_MAX_FRS  9212
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
index 0d56223f9914..da9faaf856cb 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
@@ -156,7 +156,11 @@ struct rvu_pfvf {
 struct nix_txsch {
struct rsrc_bmap schq;
u8   lvl;
-   u16  *pfvf_map;
+#define NIX_TXSCHQ_TL1_CFG_DONE   BIT_ULL(0)
+#define TXSCH_MAP_FUNC(__pfvf_map)((__pfvf_map) & 0x)
+#define TXSCH_MAP_FLAGS(__pfvf_map)   ((__pfvf_map) >> 16)
+#define TXSCH_MAP(__func, __flags)(((__func) & 0x) | ((__flags) << 16))
+   u32  *pfvf_map;
 };
 
 struct npc_pkind {
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index a258001a1cbd..90779cff1463 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -127,6 +127,7 @@ static bool is_valid_txschq(struct rvu *rvu, int blkaddr,
 {
struct nix_txsch *txsch;
struct nix_hw *nix_hw;
+   u16 map_func;
 
nix_hw = get_nix_hw(rvu->hw, blkaddr);
if (!nix_hw)
@@ -138,11 +139,18 @@ static bool is_valid_txschq(struct rvu *rvu, int blkaddr,
return false;
 
mutex_lock(>rsrc_lock);
-   if (txsch->pfvf_map[schq] != pcifunc) {
-   mutex_unlock(>rsrc_lock);
-   return false;
-   }
+   map_func = TXSCH_MAP_FUNC(txsch->pfvf_map[schq]);
mutex_unlock(>rsrc_lock);
+
+   /* For TL1 schq, sharing across VF's of same PF is ok */
+   if (lvl == NIX_TXSCH_LVL_TL1 &&
+   rvu_get_pf(map_func) != rvu_get_pf(pcifunc))
+   return false;
+
+   if (lvl != NIX_TXSCH_LVL_TL1 &&
+   map_func != pcifunc)
+   return false;
+
return true;
 }
 
@@ -494,7 +502,9 @@ static int rvu_nix_aq_enq_inst(struct rvu *rvu, struct 
nix_aq_enq_req *req,
 
/* Check if SQ pointed SMQ belongs to this PF/VF or not */
if (req->ctype == NIX_AQ_CTYPE_SQ &&
-   req->op != NIX_AQ_INSTOP_WRITE) {
+   ((req->op == NIX_AQ_INSTOP_INIT && req->sq.ena) ||
+(req->op == NIX_AQ_INSTOP_WRITE &&
+ req->sq_mask.ena && req->sq_mask.smq && req->sq.ena))) {
if (!is_valid_txschq(rvu, blkaddr, NIX_TXSCH_LVL_SMQ,
 pcifunc, req->sq.smq))
return NIX_AF_ERR_AQ_ENQUEUE;
@@ -987,6 +997,76 @@ static void nix_reset_tx_linkcfg(struct rvu *rvu, int 
blkaddr,
NIX_AF_TL3_TL2X_LINKX_CFG(schq, link), 0x00);
 }
 
+static int
+rvu_get_tl1_schqs(struct rvu *rvu,
+ int blkaddr,
+ u16 pcifunc,
+ u16 *schq_list,
+ u16 *schq_cnt)
+{
+   struct nix_txsch *txsch;
+   struct nix_hw *nix_hw;
+   struct rvu_pfvf *pfvf;
+   u8 cgx_id, lmac_id;
+   u16 schq_base;
+   u32 *pfvf_map;
+   int pf, intf;
+
+   nix_hw = get_nix_hw(rvu->hw, blkaddr);
+   if (!nix_hw)
+   return -ENODEV;
+
+   pfvf = rvu_get_pfvf(rvu, pcifunc);
+   txsch = _hw->txsch[NIX_TXSCH_LVL_TL1];
+   pfvf_map = txsch->pfvf_map;
+   pf = rvu_get_pf(pcifunc);
+
+   /* static allocation as 

[PATCH v1 net-next 04/14] octeontx2-af: Add support for runtime RSS algo index reservation

2018-12-01 Thread Jerin Jacob
From: Jerin Jacob 

Introduced reserve_flowkey_alg_idx()to reserve RSS algorithm index,
it would internally use set_flowkey_fields() to generate fields
based on the flow key dynamically.

On AF driver init, it would reserve a predefined set RSS algo indexes,
which will be available all the time for all the AF driver consumers.
The leftover algo indexes can be reserved at runtime through
exiting nix_rss_flowkey_cfg mailbox message.

The FLOW_KEY_TYPE_PORT is removed from predefined a set of RSS flow type
as it is not used by any consumer.

Signed-off-by: Jerin Jacob 
---
 .../ethernet/marvell/octeontx2/af/common.h|  14 --
 .../net/ethernet/marvell/octeontx2/af/mbox.h  |   1 +
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |   7 +
 .../ethernet/marvell/octeontx2/af/rvu_nix.c   | 187 +++---
 4 files changed, 120 insertions(+), 89 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/common.h 
b/drivers/net/ethernet/marvell/octeontx2/af/common.h
index e0a47d364982..72ad04eb8769 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/common.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/common.h
@@ -193,18 +193,4 @@ enum nix_scheduler {
 #define DEFAULT_RSS_CONTEXT_GROUP  0
 #define MAX_RSS_INDIR_TBL_SIZE 256 /* 1 << Max adder bits */
 
-/* NIX flow tag algorithm indices, max is 31 */
-enum {
-   FLOW_KEY_ALG_PORT,
-   FLOW_KEY_ALG_IP,
-   FLOW_KEY_ALG_TCP,
-   FLOW_KEY_ALG_UDP,
-   FLOW_KEY_ALG_SCTP,
-   FLOW_KEY_ALG_TCP_UDP,
-   FLOW_KEY_ALG_TCP_SCTP,
-   FLOW_KEY_ALG_UDP_SCTP,
-   FLOW_KEY_ALG_TCP_UDP_SCTP,
-   FLOW_KEY_ALG_MAX,
-};
-
 #endif /* COMMON_H */
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h 
b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
index 1e129112cc51..66aa202a3fed 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
@@ -415,6 +415,7 @@ enum nix_af_status {
NIX_AF_SMQ_FLUSH_FAILED = -413,
NIX_AF_ERR_LF_RESET = -414,
NIX_AF_ERR_RSS_NOSPC_FIELD  = -415,
+   NIX_AF_ERR_RSS_NOSPC_ALGO   = -416,
NIX_AF_INVAL_NPA_PF_FUNC= -419,
NIX_AF_INVAL_SSO_PF_FUNC= -420,
 };
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
index 48dbbaa9dd4d..0d56223f9914 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
@@ -164,9 +164,16 @@ struct npc_pkind {
u32 *pfchan_map;
 };
 
+struct nix_flowkey {
+#define FLOW_KEY_ALG_MAX 32
+   u32 flowkey[FLOW_KEY_ALG_MAX];
+   int in_use;
+};
+
 struct nix_hw {
struct nix_txsch txsch[NIX_TXSCH_LVL_CNT]; /* Tx schedulers */
struct nix_mcast mcast;
+   struct nix_flowkey flowkey;
 };
 
 struct rvu_hwinfo {
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index 5b7a0a04b529..a258001a1cbd 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -1597,54 +1597,16 @@ int rvu_mbox_handler_nix_stats_rst(struct rvu *rvu, 
struct msg_req *req,
 }
 
 /* Returns the ALG index to be set into NPC_RX_ACTION */
-static int get_flowkey_alg_idx(u32 flow_cfg)
+static int get_flowkey_alg_idx(struct nix_hw *nix_hw, u32 flow_cfg)
 {
-   u32 ip_cfg;
+   int i;
 
-   flow_cfg &= ~FLOW_KEY_TYPE_PORT;
-   ip_cfg = FLOW_KEY_TYPE_IPV4 | FLOW_KEY_TYPE_IPV6;
-   if (flow_cfg == ip_cfg)
-   return FLOW_KEY_ALG_IP;
-   else if (flow_cfg == (ip_cfg | FLOW_KEY_TYPE_TCP))
-   return FLOW_KEY_ALG_TCP;
-   else if (flow_cfg == (ip_cfg | FLOW_KEY_TYPE_UDP))
-   return FLOW_KEY_ALG_UDP;
-   else if (flow_cfg == (ip_cfg | FLOW_KEY_TYPE_SCTP))
-   return FLOW_KEY_ALG_SCTP;
-   else if (flow_cfg == (ip_cfg | FLOW_KEY_TYPE_TCP | FLOW_KEY_TYPE_UDP))
-   return FLOW_KEY_ALG_TCP_UDP;
-   else if (flow_cfg == (ip_cfg | FLOW_KEY_TYPE_TCP | FLOW_KEY_TYPE_SCTP))
-   return FLOW_KEY_ALG_TCP_SCTP;
-   else if (flow_cfg == (ip_cfg | FLOW_KEY_TYPE_UDP | FLOW_KEY_TYPE_SCTP))
-   return FLOW_KEY_ALG_UDP_SCTP;
-   else if (flow_cfg == (ip_cfg | FLOW_KEY_TYPE_TCP |
- FLOW_KEY_TYPE_UDP | FLOW_KEY_TYPE_SCTP))
-   return FLOW_KEY_ALG_TCP_UDP_SCTP;
+   /* Scan over exiting algo entries to find a match */
+   for (i = 0; i < nix_hw->flowkey.in_use; i++)
+   if (nix_hw->flowkey.flowkey[i] == flow_cfg)
+   return i;
 
-   return FLOW_KEY_ALG_PORT;
-}
-
-int rvu_mbox_handler_nix_rss_flowkey_cfg(struct rvu *rvu,
-struct nix_rss_flowkey_cfg *req,
-struct nix_rss_flowkey_cfg_rsp *rsp)
-{
-   struct rvu_hwinfo *hw = rvu->hw;

[PATCH v1 net-next 00/14] octeontx2-af: NIX and NPC enhancements

2018-12-01 Thread Jerin Jacob
From: Jerin Jacob 

This patchset is a continuation to earlier submitted four patch
series to add a new driver for Marvell's OcteonTX2 SOC's
Resource virtualization unit (RVU) admin function driver.

1. octeontx2-af: Add RVU Admin Function driver
   https://www.spinics.net/lists/netdev/msg528272.html
2. octeontx2-af: NPA and NIX blocks initialization
   https://www.spinics.net/lists/netdev/msg529163.html
3. octeontx2-af: NPC parser and NIX blocks initialization
   https://www.spinics.net/lists/netdev/msg530252.html
4. octeontx2-af: NPC MCAM support and FLR handling
   https://www.spinics.net/lists/netdev/msg534392.html

This patch series adds support for below

NPC block:
- Add NPC(mkex) profile support for various Key extraction configurations

NIX block:
- Enable dynamic RSS flow key algorithm configuration
- Enhancements on Rx checksum and error checks
- Add support for Tx packet marking support
- TL1 schedule queue allocation enhancements
- Add LSO format configuration mbox
- VLAN TPID configuration
- Skip multicast entry init for broadcast tables

Jerin Jacob (5):
  octeontx2-af: Add response for RSS flow key cfg message
  octeontx2-af: Add support for dynamic flow cfg to RSS field generation
  octeontx2-af: Add support for runtime RSS algo index reservation
  octeontx2-af: Enable inner IPv4 checksum and its error code
  octeontx2-af: Define all NIX_AF_RX_DEF_* registers

Krzysztof Kanas (1):
  octeontx2-af: Add support for Tx packet marking

Nithin Dabilpuram (4):
  octeontx2-af: Restrict TL1 allocation and configuration
  octeontx2-af: Allow freeing single TLx Tx schedule queue
  octeontx2-af: Configure VLAN TPIDs
  octeontx2-af: Add LSO format configuration mailbox

Sunil Goutham (1):
  octeontx2-af: Skip NIXLF check for bcast MCE entry

Vamsi Attunuru (2):
  octeontx2-af: Enable RSS with promiscuous mode
  octeontx2-af: Enable mkex profile

Vidhya Raman (1):
  octeontx2-af: Add L3 and L4 packet verification mailbox

 .../net/ethernet/marvell/octeontx2/af/cgx.c   |  54 ++
 .../net/ethernet/marvell/octeontx2/af/cgx.h   |   1 +
 .../ethernet/marvell/octeontx2/af/cgx_fw_if.h |  12 +
 .../ethernet/marvell/octeontx2/af/common.h|  25 +-
 .../net/ethernet/marvell/octeontx2/af/mbox.h  |  62 +-
 .../net/ethernet/marvell/octeontx2/af/npc.h   |  18 +
 .../net/ethernet/marvell/octeontx2/af/rvu.c   |  15 +
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |  40 +-
 .../ethernet/marvell/octeontx2/af/rvu_nix.c   | 864 +++---
 .../ethernet/marvell/octeontx2/af/rvu_npc.c   | 157 +++-
 10 files changed, 1079 insertions(+), 169 deletions(-)

-- 
2.19.2



[PATCH v1 net-next 01/14] octeontx2-af: Skip NIXLF check for bcast MCE entry

2018-12-01 Thread Jerin Jacob
From: Sunil Goutham 

At the time of initial broadcast packet replication table init,
NIXLFs are not yet attached to PF_FUNCs. Hence skipped checking
NIXLF while submitting MCE entry init instruction to NIX admin queue.

Also did a minor cleanup while installing bcast match entry in
packet parser unit i.e NPC.

Signed-off-by: Sunil Goutham 
Signed-off-by: Jerin Jacob 
---
 .../net/ethernet/marvell/octeontx2/af/rvu_nix.c| 14 +-
 .../net/ethernet/marvell/octeontx2/af/rvu_npc.c|  2 +-
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index 962a82f7d141..183331448cf0 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -431,9 +431,8 @@ static int rvu_nix_aq_enq_inst(struct rvu *rvu, struct 
nix_aq_enq_req *req,
bool ena;
u64 cfg;
 
-   pfvf = rvu_get_pfvf(rvu, pcifunc);
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, pcifunc);
-   if (!pfvf->nixlf || blkaddr < 0)
+   if (blkaddr < 0)
return NIX_AF_ERR_AF_LF_INVALID;
 
block = >block[blkaddr];
@@ -443,9 +442,14 @@ static int rvu_nix_aq_enq_inst(struct rvu *rvu, struct 
nix_aq_enq_req *req,
return NIX_AF_ERR_AQ_ENQUEUE;
}
 
+   pfvf = rvu_get_pfvf(rvu, pcifunc);
nixlf = rvu_get_lf(rvu, block, pcifunc, 0);
-   if (nixlf < 0)
-   return NIX_AF_ERR_AF_LF_INVALID;
+
+   /* Skip NIXLF check for broadcast MCE entry init */
+   if (!(!rsp && req->ctype == NIX_AQ_CTYPE_MCE)) {
+   if (!pfvf->nixlf || nixlf < 0)
+   return NIX_AF_ERR_AF_LF_INVALID;
+   }
 
switch (req->ctype) {
case NIX_AQ_CTYPE_RQ:
@@ -1295,7 +1299,7 @@ static int nix_setup_mce(struct rvu *rvu, int mce, u8 op,
struct nix_aq_enq_req aq_req;
int err;
 
-   aq_req.hdr.pcifunc = pcifunc;
+   aq_req.hdr.pcifunc = 0;
aq_req.ctype = NIX_AQ_CTYPE_MCE;
aq_req.op = op;
aq_req.qidx = mce;
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
index 6ea2b0e2df42..ee2600d93d54 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
@@ -476,7 +476,7 @@ void rvu_npc_install_bcast_match_entry(struct rvu *rvu, u16 
pcifunc,
 *
 */
entry.kw[0] = BIT_ULL(13) | chan;
-   entry.kw_mask[0] = ~entry.kw[0] & (BIT_ULL(13) | 0xFFFULL);
+   entry.kw_mask[0] = BIT_ULL(13) | 0xFFFULL;
 
*(u64 *) = 0x00;
 #ifdef MCAST_MCE
-- 
2.19.2



[PATCH v1 net-next 02/14] octeontx2-af: Add response for RSS flow key cfg message

2018-12-01 Thread Jerin Jacob
From: Jerin Jacob 

Added response for nix_rss_flowkey_cfg message to return
selected RSS algorithm index.

The FLOW_KEY_TYPE* definition is part of the mbox message and
it will be used by the other consumers of AF driver hence moving to mbox.h.

Signed-off-by: Jerin Jacob 
---
 drivers/net/ethernet/marvell/octeontx2/af/common.h |  8 
 drivers/net/ethernet/marvell/octeontx2/af/mbox.h   | 14 +-
 drivers/net/ethernet/marvell/octeontx2/af/rvu.h|  2 +-
 .../net/ethernet/marvell/octeontx2/af/rvu_nix.c|  4 ++--
 4 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/common.h 
b/drivers/net/ethernet/marvell/octeontx2/af/common.h
index 9bddb032dd7e..e0a47d364982 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/common.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/common.h
@@ -193,14 +193,6 @@ enum nix_scheduler {
 #define DEFAULT_RSS_CONTEXT_GROUP  0
 #define MAX_RSS_INDIR_TBL_SIZE 256 /* 1 << Max adder bits */
 
-/* NIX flow tag, key type flags */
-#define FLOW_KEY_TYPE_PORT BIT(0)
-#define FLOW_KEY_TYPE_IPV4 BIT(1)
-#define FLOW_KEY_TYPE_IPV6 BIT(2)
-#define FLOW_KEY_TYPE_TCP  BIT(3)
-#define FLOW_KEY_TYPE_UDP  BIT(4)
-#define FLOW_KEY_TYPE_SCTP BIT(5)
-
 /* NIX flow tag algorithm indices, max is 31 */
 enum {
FLOW_KEY_ALG_PORT,
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h 
b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
index 292c13a901df..4cce31fb13ab 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
@@ -193,7 +193,8 @@ M(NIX_TXSCHQ_CFG,   0x8006, nix_txschq_cfg, 
nix_txschq_config, msg_rsp)  \
 M(NIX_STATS_RST,   0x8007, nix_stats_rst, msg_req, msg_rsp)\
 M(NIX_VTAG_CFG,0x8008, nix_vtag_cfg, nix_vtag_config, msg_rsp) 
\
 M(NIX_RSS_FLOWKEY_CFG,  0x8009, nix_rss_flowkey_cfg,   \
-nix_rss_flowkey_cfg, msg_rsp)  \
+nix_rss_flowkey_cfg,   \
+nix_rss_flowkey_cfg_rsp)   \
 M(NIX_SET_MAC_ADDR,0x800a, nix_set_mac_addr, nix_set_mac_addr, msg_rsp) \
 M(NIX_SET_RX_MODE, 0x800b, nix_set_rx_mode, nix_rx_mode, msg_rsp)  \
 M(NIX_SET_HW_FRS,  0x800c, nix_set_hw_frs, nix_frs_cfg, msg_rsp)   \
@@ -561,9 +562,20 @@ struct nix_rss_flowkey_cfg {
struct mbox_msghdr hdr;
int mcam_index;  /* MCAM entry index to modify */
u32 flowkey_cfg; /* Flowkey types selected */
+#define FLOW_KEY_TYPE_PORT BIT(0)
+#define FLOW_KEY_TYPE_IPV4 BIT(1)
+#define FLOW_KEY_TYPE_IPV6 BIT(2)
+#define FLOW_KEY_TYPE_TCP  BIT(3)
+#define FLOW_KEY_TYPE_UDP  BIT(4)
+#define FLOW_KEY_TYPE_SCTP BIT(5)
u8  group;   /* RSS context or group */
 };
 
+struct nix_rss_flowkey_cfg_rsp {
+   struct mbox_msghdr hdr;
+   u8  alg_idx; /* Selected algo index */
+};
+
 struct nix_set_mac_addr {
struct mbox_msghdr hdr;
u8 mac_addr[ETH_ALEN]; /* MAC address to be set for this pcifunc */
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
index ae8e2e206c87..48dbbaa9dd4d 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
@@ -398,7 +398,7 @@ int rvu_mbox_handler_nix_rxvlan_alloc(struct rvu *rvu, 
struct msg_req *req,
  struct msg_rsp *rsp);
 int rvu_mbox_handler_nix_rss_flowkey_cfg(struct rvu *rvu,
 struct nix_rss_flowkey_cfg *req,
-struct msg_rsp *rsp);
+struct nix_rss_flowkey_cfg_rsp *rsp);
 int rvu_mbox_handler_nix_set_mac_addr(struct rvu *rvu,
  struct nix_set_mac_addr *req,
  struct msg_rsp *rsp);
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index 183331448cf0..76fec9928ab7 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -1626,7 +1626,7 @@ static int get_flowkey_alg_idx(u32 flow_cfg)
 
 int rvu_mbox_handler_nix_rss_flowkey_cfg(struct rvu *rvu,
 struct nix_rss_flowkey_cfg *req,
-struct msg_rsp *rsp)
+struct nix_rss_flowkey_cfg_rsp *rsp)
 {
struct rvu_hwinfo *hw = rvu->hw;
u16 pcifunc = req->hdr.pcifunc;
@@ -1641,7 +1641,7 @@ int rvu_mbox_handler_nix_rss_flowkey_cfg(struct rvu *rvu,
return NIX_AF_ERR_AF_LF_INVALID;
 
alg_idx = get_flowkey_alg_idx(req->flowkey_cfg);
-
+   rsp->alg_idx = alg_idx;

[PATCH bpf] mips: bpf: fix encoding bug for mm_srlv32_op

2018-12-01 Thread Jiong Wang
For micro-mips, srlv inside POOL32A encoding space should use 0x50
sub-opcode, NOT 0x90.

Some early version ISA doc describes the encoding as 0x90 for both srlv and
srav, this looks to me was a typo. I checked Binutils libopcode
implementation which is using 0x50 for srlv and 0x90 for srav.

Fixes: f31318fdf324 ("MIPS: uasm: Add srlv uasm instruction")
CC: Markos Chandras 
CC: Paul Burton 
Acked-by: Jakub Kicinski 
Signed-off-by: Jiong Wang 
---
 arch/mips/include/uapi/asm/inst.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/include/uapi/asm/inst.h 
b/arch/mips/include/uapi/asm/inst.h
index c05dcf5..80f35e7 100644
--- a/arch/mips/include/uapi/asm/inst.h
+++ b/arch/mips/include/uapi/asm/inst.h
@@ -370,7 +370,7 @@ enum mm_32a_minor_op {
mm_pool32axf_op = 0x03c,
mm_srl32_op = 0x040,
mm_sra_op = 0x080,
-   mm_srlv32_op = 0x090,
+   mm_srlv32_op = 0x050,
mm_rotr_op = 0x0c0,
mm_lwxs_op = 0x118,
mm_addu32_op = 0x150,
-- 
2.7.4



Re: [PATCH iproute2] tc: add a missing space between rate estimator and backlog

2018-12-01 Thread Jiri Pirko
Fri, Nov 30, 2018 at 02:57:02PM CET, eduma...@google.com wrote:
>When a rate estimator is active, "tc -s qd" displays
>something like :
>
>rate 12616bit 11ppsbacklog 0b 0p requeues 2
>
>instead of :
>
>rate 12616bit 11pps backlog 0b 0p requeues 2
>
>Fixes: 4fcec7f3665b ("tc: jsonify stats2")
>Signed-off-by: Eric Dumazet 
>Cc: Jiri Pirko 

Reviewed-by: Jiri Pirko