RE: [dpdk-dev] [RFC PATCH] ethdev: support priority based flow control

2021-11-28 Thread Ori Kam
Good for me

Please send meeting inviate.

Ori

> -Original Message-
> From: Jerin Jacob 
> Sent: Friday, November 26, 2021 8:46 AM
> To: Ori Kam 
> Subject: Re: [dpdk-dev] [RFC PATCH] ethdev: support priority based flow 
> control
> 
> On Thu, Nov 25, 2021 at 7:32 PM Ori Kam  wrote:
> >
> > Hi Jerin,
> >
> > I think that we are not on the same page and I'm missing some critical info 
> > to decide
> > on the best approch.
> >
> > Can we please have a short meeting so you can explain to me about this 
> > feature?
> >
> > I think it will be good if Thomas, Ferruh and Andrew could join.
> 
> Sure, Ori. Is 2 PM UTC on 29th Nov(Monday) on
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmeet.jit.si%2Fdpdk&dat
> a=04%7C01%7Corika%40nvidia.com%7C515af20d94c0419f1e2208d9b0a88983%7C43083d15727340c1b7
> db39efd9ccc17a%7C0%7C0%7C637735060187259293%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wL
> jAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=V3n8P%2F%2BM
> udw4IMntVry8PO71PgxBAJyS9QYfTJN5i7A%3D&reserved=0
> is fine for you/Thomas/Ferruh/Andrew?
> If not, Please suggest some time.
> 
> 
> >
> > Best,
> > Ori
> >
> > > -Original Message-
> > > From: Jerin Jacob 
> > > Sent: Thursday, November 25, 2021 1:12 PM
> > > To: Ori Kam 
> > > Subject: Re: [dpdk-dev] [RFC PATCH] ethdev: support priority based flow 
> > > control
> > >
> > > On Wed, Nov 24, 2021 at 9:30 PM Ori Kam  wrote:
> > > >
> > > >
> > > >
> > > > > -Original Message-
> > > > > From: Jerin Jacob 
> > > > > Sent: Wednesday, November 24, 2021 12:48 PM
> > > > >
> > > > > On Wed, Nov 24, 2021 at 3:01 PM Ori Kam  wrote:
> > > > > >
> > > > > > Hi Jerin,
> > > > > >
> > > > > > > -Original Message-
> > > > > > > From: Jerin Jacob 
> > > > > > > Sent: Tuesday, November 23, 2021 12:58 PM
> > > > > > > To: Ori Kam 
> > > > > > >
> > > > > > > On Sun, Nov 21, 2021 at 3:20 PM Ori Kam  wrote:
> > > > > > > >
> > > > > > > > Hi Jerin,
> > > > > > >
> > > > > > > Hi Ori,
> > > > > > >
> > > > > > > >
> > > > > > > > Sorry for my late response,
> > > > > > >
> > > > > > > Thanks for the review.
> > > > > > >
> > > > > > > >
> > > > > > > > > -Original Message-
> > > > > > > > > From: Jerin Jacob 
> > > > > > > > > Sent: Wednesday, November 17, 2021 11:49 AM
> > > > > > > > > To: Jerin Jacob 
> > > > > > > > > Subject: Re: [dpdk-dev] [RFC PATCH] ethdev: support priority 
> > > > > > > > > based flow control
> > > > > > > > >
> > > > > > > > > On Tue, Oct 5, 2021 at 6:32 PM  wrote:
> > > > > > > > > >
> > > > > > > > > > From: Jerin Jacob 
> > > > > > > > > >
> > > > > > > > > > rte_eth_dev_priority_flow_ctrl_set() based API is not 
> > > > > > > > > > generic as it
> > > > > > > > > > can not support other than VLAN priority mapping to PFC 
> > > > > > > > > > traffic class.
> > > > > > > > > >
> > > > > > > > > > Introducing RTE_FLOW_ACTION_TYPE_PFC_SET_TC rte_flow action 
> > > > > > > > > > to
> > > > > > > > > > set the traffic class as per 802.1Qbb specification. This 
> > > > > > > > > > will enable,
> > > > > > > > > > Traffic class(8bit) to be selected based on any packet 
> > > > > > > > > > field like DSCP.
> > > > > > > > > >
> > > > > > > > > > Also, making it as rte_flow action will enable fine control 
> > > > > > > > > > on
> > > > > > > > > > traffic class selection to a specific queue or VF etc.
> > > > > > > > > >
> > > > > > > > > > Signed-off-by: Jerin Jacob 
> > > > > > > > >
> > > > > > > > > Ping. If there are no comments on RFC, Planning to send v1 
> > > > > > > > > for 22.02.
> > > > > > > >
> > > > > > > > All the set type of functions are going to be deprecated.
> > > > > > > > you should use RTE_FLOW_ACTION_TYPE_MODIFY_FIELD.
> > > > > > > >
> > > > > > > > What is the item that you are matching on when using rte_flow? 
> > > > > > > > Is it part of the tci in the
> vlan
> > > > > item?
> > > > > > >
> > > > > > > TC can be VLAN TCI field or DSCP field in IP header or any other 
> > > > > > > field
> > > > > > > in packet.
> > > > > > > We need to set the traffic class as per 802.1Qbb specification, 
> > > > > > > May I
> > > > > > > know how the "modify"
> > > > > > > attribute helps here. It should be a "set" operation. Right?
> > > > > > >
> > > > > >
> > > > > > Yes, in the rte_flow_action_modify_field there is what operation 
> > > > > > you want to do,
> > > > > > in this case the action should be set.
> > > > >
> > > > > But RTE_FLOW_ACTION_TYPE_MODIFY_FIELD used for modify the packet
> > > > > content[1]. RIght?
> > > > > In this case, it is more of sideband data not anything on packet
> > > > > content. If so, explicit action
> > > > > makes sense. Right?
> > > > >
> > > >
> > > > It looks like I'm missing something,
> > > > If you don't want to change the packet and this is just data,
> > > > why not use tag/mark/flag/metadata?
> > > >
> > > > Who should get this data?
> > > > If the packet is hairpined and the packet is sent to wire this info 
> > > > should be 

Re: [dpdk-dev] [RFC PATCH] ethdev: support priority based flow control

2021-11-28 Thread Jerin Jacob
On Sun, Nov 28, 2021 at 5:01 PM Ori Kam  wrote:
>
> Good for me
>
> Please send the meeting invite.


Meeting invite at 2 PM UTC on 29th Nov(Monday)

Hi there,

Jerin Jacob Kollanukkaran is inviting you to a scheduled Zoom meeting.

Topic: Jerin Jacob Kollanukkaran's Personal Meeting Room


Join Zoom Meeting:
https://marvell.zoom.us/j/9901077677?pwd=T2lTTGMwYlc1YTQzMnR4eGRWQXR6QT09
Password: 339888


Or Telephone:
Dial(for higher quality, dial a number based on your current location):
US: +1 301 715 8592  or +1 312 626 6799  or +1 346 248 7799
or +1 646 558 8656  or +1 669 900 6833  or +1 253 215 8782  or 888 788
0099 (Toll Free) or 833 548 0276 (Toll Free) or 833 548 0282 (Toll
Free) or 877 853 5247 (Toll Free)
Meeting ID: 990 107 7677
Password: 358309
International numbers available: https://marvell.zoom.us/u/adpcCpMHYt

Or a Video Conference Room:
>From Touchpad: Tap Join Zoom button. When prompted, enter 990 107 7677
Password: 358309

For China locations, from Touchpad: Dial* then 990 107 7677
Password: 358309

>
> Ori
>
> > -Original Message-
> > From: Jerin Jacob 
> > Sent: Friday, November 26, 2021 8:46 AM
> > To: Ori Kam 
> > Subject: Re: [dpdk-dev] [RFC PATCH] ethdev: support priority based flow 
> > control
> >
> > On Thu, Nov 25, 2021 at 7:32 PM Ori Kam  wrote:
> > >
> > > Hi Jerin,
> > >
> > > I think that we are not on the same page and I'm missing some critical 
> > > info to decide
> > > on the best approch.
> > >
> > > Can we please have a short meeting so you can explain to me about this 
> > > feature?
> > >
> > > I think it will be good if Thomas, Ferruh and Andrew could join.
> >
> > Sure, Ori. Is 2 PM UTC on 29th Nov(Monday) on
> > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmeet.jit.si%2Fdpdk&dat
> > a=04%7C01%7Corika%40nvidia.com%7C515af20d94c0419f1e2208d9b0a88983%7C43083d15727340c1b7
> > db39efd9ccc17a%7C0%7C0%7C637735060187259293%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wL
> > jAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=V3n8P%2F%2BM
> > udw4IMntVry8PO71PgxBAJyS9QYfTJN5i7A%3D&reserved=0
> > is fine for you/Thomas/Ferruh/Andrew?
> > If not, Please suggest some time.
> >
> >
> > >
> > > Best,
> > > Ori
> > >
> > > > -Original Message-
> > > > From: Jerin Jacob 
> > > > Sent: Thursday, November 25, 2021 1:12 PM
> > > > To: Ori Kam 
> > > > Subject: Re: [dpdk-dev] [RFC PATCH] ethdev: support priority based flow 
> > > > control
> > > >
> > > > On Wed, Nov 24, 2021 at 9:30 PM Ori Kam  wrote:
> > > > >
> > > > >
> > > > >
> > > > > > -Original Message-
> > > > > > From: Jerin Jacob 
> > > > > > Sent: Wednesday, November 24, 2021 12:48 PM
> > > > > >
> > > > > > On Wed, Nov 24, 2021 at 3:01 PM Ori Kam  wrote:
> > > > > > >
> > > > > > > Hi Jerin,
> > > > > > >
> > > > > > > > -Original Message-
> > > > > > > > From: Jerin Jacob 
> > > > > > > > Sent: Tuesday, November 23, 2021 12:58 PM
> > > > > > > > To: Ori Kam 
> > > > > > > >
> > > > > > > > On Sun, Nov 21, 2021 at 3:20 PM Ori Kam  
> > > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > Hi Jerin,
> > > > > > > >
> > > > > > > > Hi Ori,
> > > > > > > >
> > > > > > > > >
> > > > > > > > > Sorry for my late response,
> > > > > > > >
> > > > > > > > Thanks for the review.
> > > > > > > >
> > > > > > > > >
> > > > > > > > > > -Original Message-
> > > > > > > > > > From: Jerin Jacob 
> > > > > > > > > > Sent: Wednesday, November 17, 2021 11:49 AM
> > > > > > > > > > To: Jerin Jacob 
> > > > > > > > > > Subject: Re: [dpdk-dev] [RFC PATCH] ethdev: support 
> > > > > > > > > > priority based flow control
> > > > > > > > > >
> > > > > > > > > > On Tue, Oct 5, 2021 at 6:32 PM  wrote:
> > > > > > > > > > >
> > > > > > > > > > > From: Jerin Jacob 
> > > > > > > > > > >
> > > > > > > > > > > rte_eth_dev_priority_flow_ctrl_set() based API is not 
> > > > > > > > > > > generic as it
> > > > > > > > > > > can not support other than VLAN priority mapping to PFC 
> > > > > > > > > > > traffic class.
> > > > > > > > > > >
> > > > > > > > > > > Introducing RTE_FLOW_ACTION_TYPE_PFC_SET_TC rte_flow 
> > > > > > > > > > > action to
> > > > > > > > > > > set the traffic class as per 802.1Qbb specification. This 
> > > > > > > > > > > will enable,
> > > > > > > > > > > Traffic class(8bit) to be selected based on any packet 
> > > > > > > > > > > field like DSCP.
> > > > > > > > > > >
> > > > > > > > > > > Also, making it as rte_flow action will enable fine 
> > > > > > > > > > > control on
> > > > > > > > > > > traffic class selection to a specific queue or VF etc.
> > > > > > > > > > >
> > > > > > > > > > > Signed-off-by: Jerin Jacob 
> > > > > > > > > >
> > > > > > > > > > Ping. If there are no comments on RFC, Planning to send v1 
> > > > > > > > > > for 22.02.
> > > > > > > > >
> > > > > > > > > All the set type of functions are going to be deprecated.
> > > > > > > > > you should use RTE_FLOW_ACTION_TYPE_MODIFY_FIELD.
> > > > > > > > >
> > > >

RE: [dpdk-dev] [ovs-dev] ovs-vswitchd with DPDK crashed when guest VM restarts network service

2021-11-28 Thread Bendror, Eran (Nokia - US)
Hi,

Internally the VM is using DPDK 17.05, on Centos7.9 – but this seems to be 
reproducing with guest level 18.11 as well.

The issue is when the DPDK PMDs get started at guest, so the assumption is that 
that presents bad / inaccessible memory towards the host.

We did notice some mis-use at the guest of selinux permissions, and removing 
that helped reducing the frequency significantly.

Is there a way to map the shared memory between VM and host to see where is the 
segmentation fault coming from?

I will see if I can upload the VM xml, but it is a multi-queue 4 port VM.

Thanks for the assistance,
Eran

From: Xia, Chenbo 
Sent: Friday, November 26, 2021 4:25 AM
To: Bendror, Eran (Nokia - US) ; ktray...@redhat.com
Cc: a...@cisco.com; dev@dpdk.org; Stokes, Ian ; 
maxime.coque...@redhat.com; y...@cisco.com; Marco Varlese 

Subject: RE: [dpdk-dev] [ovs-dev] ovs-vswitchd with DPDK crashed when guest VM 
restarts network service

Hi,

Is it possible that you can provide more info about this isuee. I mean: qemu 
cmdline/libvirt xml, ovs cmdline, guest driver version and etc… Or it’s hard to 
reproduce the issue.

Thanks,
Chenbo

From: Bendror, Eran (Nokia - US) 
mailto:eran.bend...@nokia.com>>
Sent: Wednesday, November 17, 2021 10:42 PM
To: ktray...@redhat.com
Cc: a...@cisco.com; Xia, Chenbo 
mailto:chenbo@intel.com>>; 
dev@dpdk.org; Stokes, Ian 
mailto:ian.sto...@intel.com>>; 
maxime.coque...@redhat.com; 
y...@cisco.com
Subject: Re: [dpdk-dev] [ovs-dev] ovs-vswitchd with DPDK crashed when guest VM 
restarts network service

Hello,

I am wondering if there was any progress in this topic, we are seeing a very 
similar issue, where a VM level application restart triggers segmentation fault 
and failed to allocate MBuf on the host level

CentOS Linux release 7.8.2003 (Core)
dpdk-18.11.5-1.el7_8.x86_64
openvswitch-2.11.0-4.el7.x86_64
libvirt 4.5.0
QEMU 4.5.0 (API)
QEMU 2.12.0
3.10.0-1127.13.1.el7.x86_64

And we get the same crash

#0  0x7f96cb72e7ee in rte_memcpy_generic () from /lib64/librte_vhost.so.4
#1  0x7f96cb7350f2 in rte_vhost_dequeue_burst () from 
/lib64/librte_vhost.so.4
#2  0x7f96caf97f03 in netdev_dpdk_vhost_rxq_recv () from 
/lib64/libopenvswitch-2.11.so.0
#3  0x7f96caed21e6 in netdev_rxq_recv () from 
/lib64/libopenvswitch-2.11.so.0
#4  0x7f96caea07ca in dp_netdev_process_rxq_port () from 
/lib64/libopenvswitch-2.11.so.0
#5  0x7f96caea0ca5 in pmd_thread_main () from 
/lib64/libopenvswitch-2.11.so.0
#6  0x7f96caf2da3f in ovsthread_wrapper () from 
/lib64/libopenvswitch-2.11.so.0
#7  0x7f96c9ef3ea5 in start_thread () from /lib64/libpthread.so.0
#8  0x7f96c94118dd in clone () from /lib64/libc.so.6

We have tried upgrading host level artifacts:

dpdk-20.11.3-1.el7.x86_64
openvswitch-2.16.1-1.el7.x86_64

With backtrace:

#0  0x7f6b8b49748c in virtio_dev_tx_split_legacy () from 
/lib64/librte_vhost.so.21
#1  0x7f6b8b4c0fdb in rte_vhost_dequeue_burst () from 
/lib64/librte_vhost.so.21
#2  0x55bd714c2802 in netdev_dpdk_vhost_rxq_recv ()
#3  0x55bd713f8e51 in netdev_rxq_recv ()
#4  0x55bd713c9d2a in dp_netdev_process_rxq_port ()
#5  0x55bd713ca1f9 in pmd_thread_main ()
#6  0x55bd71455cdf in ovsthread_wrapper ()
#7  0x7f6b8a6a9ea5 in start_thread () from /lib64/libpthread.so.0
#8  0x7f6b89bc78dd in clone () from /lib64/libc.so.6

Regards,
Eran



[PATCH v2] kni: fix ioctl signature

2021-11-28 Thread Markus Theil
From: Markus Theil 

Fix kni's ioctl signature to correctly match the kernel's
structs. This shaves off the (void*) casts and uses struct file*
instead of struct inode*. With the correct signature, control flow
integrity checkers are no longer confused at this point.

Signed-off-by: Markus Theil 
Tested-by: Michael Pfeiffer 
---
v2: adapt to suggestions from Ferruh Yigit

 kernel/linux/kni/kni_misc.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c
index f10dcd069d..8d56006512 100644
--- a/kernel/linux/kni/kni_misc.c
+++ b/kernel/linux/kni/kni_misc.c
@@ -482,10 +482,10 @@ kni_ioctl_release(struct net *net, uint32_t ioctl_num,
return ret;
 }
 
-static int
-kni_ioctl(struct inode *inode, uint32_t ioctl_num, unsigned long ioctl_param)
+static long
+kni_ioctl(struct file *file, uint32_t ioctl_num, unsigned long ioctl_param)
 {
-   int ret = -EINVAL;
+   long ret = -EINVAL;
struct net *net = current->nsproxy->net_ns;
 
pr_debug("IOCTL num=0x%0x param=0x%0lx\n", ioctl_num, ioctl_param);
@@ -511,8 +511,8 @@ kni_ioctl(struct inode *inode, uint32_t ioctl_num, unsigned 
long ioctl_param)
return ret;
 }
 
-static int
-kni_compat_ioctl(struct inode *inode, uint32_t ioctl_num,
+static long
+kni_compat_ioctl(struct file *file, uint32_t ioctl_num,
unsigned long ioctl_param)
 {
/* 32 bits app on 64 bits OS to be supported later */
@@ -525,8 +525,8 @@ static const struct file_operations kni_fops = {
.owner = THIS_MODULE,
.open = kni_open,
.release = kni_release,
-   .unlocked_ioctl = (void *)kni_ioctl,
-   .compat_ioctl = (void *)kni_compat_ioctl,
+   .unlocked_ioctl = kni_ioctl,
+   .compat_ioctl = kni_compat_ioctl,
 };
 
 static struct miscdevice kni_misc = {
-- 
2.34.1



[DPDK 22.02 PATCH v2 00/10] Add cnxk_gpio PMD

2021-11-28 Thread Tomasz Duszynski
This series introduces a new rawdevice PMD which allows
to manage userspace GPIOs and install custom GPIO interrupt
handlers which bypass kernel. This is especially useful for
applications that, besides providing standard dataplane functionality,
want to have fast and low latency access to GPIO pin state.

It'd be great to have that merged during 22.02 merge window.

v2:
- do not trigger irq by writing to /dev/mem, use ioctl() instead

Tomasz Duszynski (10):
  raw/cnxk_gpio: add GPIO driver skeleton
  raw/cnxk_gpio: support reading default queue conf
  raw/cnxk_gpio: support reading queue count
  raw/cnxk_gpio: support queue setup
  raw/cnxk_gpio: support queue release
  raw/cnxk_gpio: support enqueuing buffers
  raw/cnxk_gpio: support dequeuing buffers
  raw/cnxk_gpio: support standard GPIO operations
  raw/cnxk_gpio: support custom irq handlers
  raw/cnxk_gpio: support selftest

 doc/guides/rawdevs/cnxk_gpio.rst   | 195 +++
 doc/guides/rawdevs/index.rst   |   1 +
 drivers/raw/cnxk_gpio/cnxk_gpio.c  | 633 +
 drivers/raw/cnxk_gpio/cnxk_gpio.h  |  33 ++
 drivers/raw/cnxk_gpio/cnxk_gpio_irq.c  | 216 +++
 drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c | 386 +
 drivers/raw/cnxk_gpio/meson.build  |  11 +
 drivers/raw/cnxk_gpio/rte_pmd_cnxk_gpio.h  | 429 ++
 drivers/raw/cnxk_gpio/version.map  |   3 +
 drivers/raw/meson.build|   1 +
 10 files changed, 1908 insertions(+)
 create mode 100644 doc/guides/rawdevs/cnxk_gpio.rst
 create mode 100644 drivers/raw/cnxk_gpio/cnxk_gpio.c
 create mode 100644 drivers/raw/cnxk_gpio/cnxk_gpio.h
 create mode 100644 drivers/raw/cnxk_gpio/cnxk_gpio_irq.c
 create mode 100644 drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c
 create mode 100644 drivers/raw/cnxk_gpio/meson.build
 create mode 100644 drivers/raw/cnxk_gpio/rte_pmd_cnxk_gpio.h
 create mode 100644 drivers/raw/cnxk_gpio/version.map

--
2.25.1



[PATCH v2 01/10] raw/cnxk_gpio: add GPIO driver skeleton

2021-11-28 Thread Tomasz Duszynski
Add initial support for PMD that allows to control particular pins form
userspace. Moreover PMD allows to attach custom interrupt handlers to
controllable GPIOs.

Main users of this PMD are dataplain applications requiring fast and low
latency access to pin state.

Signed-off-by: Tomasz Duszynski 
---
 doc/guides/rawdevs/cnxk_gpio.rst  |  65 +
 doc/guides/rawdevs/index.rst  |   1 +
 drivers/raw/cnxk_gpio/cnxk_gpio.c | 235 ++
 drivers/raw/cnxk_gpio/cnxk_gpio.h |  22 +++
 drivers/raw/cnxk_gpio/meson.build |   8 +
 drivers/raw/cnxk_gpio/version.map |   3 +
 drivers/raw/meson.build   |   1 +
 7 files changed, 335 insertions(+)
 create mode 100644 doc/guides/rawdevs/cnxk_gpio.rst
 create mode 100644 drivers/raw/cnxk_gpio/cnxk_gpio.c
 create mode 100644 drivers/raw/cnxk_gpio/cnxk_gpio.h
 create mode 100644 drivers/raw/cnxk_gpio/meson.build
 create mode 100644 drivers/raw/cnxk_gpio/version.map

diff --git a/doc/guides/rawdevs/cnxk_gpio.rst b/doc/guides/rawdevs/cnxk_gpio.rst
new file mode 100644
index 00..868302d07f
--- /dev/null
+++ b/doc/guides/rawdevs/cnxk_gpio.rst
@@ -0,0 +1,65 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+Copyright(c) 2021 Marvell.
+
+Marvell CNXK GPIO Driver
+
+
+CNXK GPIO PMD configures and manages GPIOs available on the system using
+standard enqueue/dequeue mechanism offered by raw device abstraction. PMD 
relies
+both on standard sysfs GPIO interface provided by the Linux kernel and GPIO
+kernel driver custom interface allowing one to install userspace interrupt
+handlers.
+
+Features
+
+
+Following features are available:
+
+- export/unexport a GPIO
+- read/write specific value from/to exported GPIO
+- set GPIO direction
+- set GPIO edge that triggers interrupt
+- set GPIO active low
+- register interrupt handler for specific GPIO
+
+Requirements
+
+
+PMD relies on modified kernel GPIO driver which exposes ``ioctl()`` interface
+for installing interrupt handlers for low latency signal processing.
+
+Driver is shipped with Marvell SDK.
+
+Device Setup
+
+
+CNXK GPIO PMD binds to virtual device which gets created by passing
+`--vdev=cnxk_gpio,gpiochip=` command line to EAL. `gpiochip` parameter
+tells PMD which GPIO controller should be used. Available controllers are
+available under `/sys/class/gpio`. For further details on how Linux represents
+GPIOs in userspace please refer to
+`sysfs.txt `_.
+
+If `gpiochip=` was omitted then first gpiochip from the alphabetically
+sort list of available gpiochips is used.
+
+.. code-block:: console
+
+   $ ls /sys/class/gpio
+   export gpiochip448 unexport
+
+In above scenario only one GPIO controller is present hence
+`--vdev=cnxk_gpio,gpiochip=448` should be passed to EAL.
+
+Before performing actual data transfer one needs to call
+``rte_rawdev_queue_count()`` followed by ``rte_rawdev_queue_conf_get()``. The
+former returns number GPIOs available in the system irrespective of GPIOs
+being controllable or not. Thus it is user responsibility to pick the proper
+ones. The latter call simply returns queue capacity.
+
+Respective queue needs to be configured with ``rte_rawdev_queue_setup()``. This
+call barely exports GPIO to userspace.
+
+To perform actual data transfer use standard ``rte_rawdev_enqueue_buffers()``
+and ``rte_rawdev_dequeue_buffers()`` APIs. Not all messages produce sensible
+responses hence dequeueing is not always necessary.
diff --git a/doc/guides/rawdevs/index.rst b/doc/guides/rawdevs/index.rst
index b6cf917443..0c02da6e90 100644
--- a/doc/guides/rawdevs/index.rst
+++ b/doc/guides/rawdevs/index.rst
@@ -12,6 +12,7 @@ application through rawdev API.
 :numbered:
 
 cnxk_bphy
+cnxk_gpio
 dpaa2_cmdif
 dpaa2_qdma
 ifpga
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
new file mode 100644
index 00..bcce4b8fb7
--- /dev/null
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -0,0 +1,235 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "cnxk_gpio.h"
+
+#define CNXK_GPIO_BUFSZ 128
+#define CNXK_GPIO_CLASS_PATH "/sys/class/gpio"
+
+static const char *const cnxk_gpio_args[] = {
+#define CNXK_GPIO_ARG_GPIOCHIP "gpiochip"
+   CNXK_GPIO_ARG_GPIOCHIP,
+   NULL
+};
+
+static void
+cnxk_gpio_format_name(char *name, size_t len)
+{
+   snprintf(name, len, "cnxk_gpio");
+}
+
+static int
+cnxk_gpio_filter_gpiochip(const struct dirent *dirent)
+{
+   const char *pattern = "gpiochip";
+
+   return !strncmp(dirent->d_name, pattern, strlen(pattern));
+}
+
+static void
+cnxk_gpio_set_defaults(struct cnxk_gpiochip *gpiochip)
+{
+   struct dirent **namelist;
+   int n;
+
+   n = scandir(CNXK_GPIO_CLASS_PATH, &namelist, cnxk_gpio_filter_gpiochip,
+   

[PATCH v2 02/10] raw/cnxk_gpio: support reading default queue conf

2021-11-28 Thread Tomasz Duszynski
Add support for reading default queue configuration.

Signed-off-by: Tomasz Duszynski 
---
 drivers/raw/cnxk_gpio/cnxk_gpio.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index bcce4b8fb7..deedf98af2 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -134,7 +134,26 @@ cnxk_gpio_read_attr_int(char *attr, int *val)
return 0;
 }
 
+static int
+cnxk_gpio_queue_def_conf(struct rte_rawdev *dev, uint16_t queue_id,
+rte_rawdev_obj_t queue_conf, size_t queue_conf_size)
+{
+   unsigned int *conf;
+
+   RTE_SET_USED(dev);
+   RTE_SET_USED(queue_id);
+
+   if (queue_conf_size != sizeof(*conf))
+   return -EINVAL;
+
+   conf = (unsigned int *)queue_conf;
+   *conf = 1;
+
+   return 0;
+}
+
 static const struct rte_rawdev_ops cnxk_gpio_rawdev_ops = {
+   .queue_def_conf = cnxk_gpio_queue_def_conf,
 };
 
 static int
-- 
2.25.1



[PATCH v2 03/10] raw/cnxk_gpio: support reading queue count

2021-11-28 Thread Tomasz Duszynski
Add support for reading number of available queues. Single queue
corresponds to GPIO.

Signed-off-by: Tomasz Duszynski 
---
 drivers/raw/cnxk_gpio/cnxk_gpio.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index deedf98af2..84be7f861e 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -152,8 +152,17 @@ cnxk_gpio_queue_def_conf(struct rte_rawdev *dev, uint16_t 
queue_id,
return 0;
 }
 
+static uint16_t
+cnxk_gpio_queue_count(struct rte_rawdev *dev)
+{
+   struct cnxk_gpiochip *gpiochip = dev->dev_private;
+
+   return gpiochip->num_gpios;
+}
+
 static const struct rte_rawdev_ops cnxk_gpio_rawdev_ops = {
.queue_def_conf = cnxk_gpio_queue_def_conf,
+   .queue_count = cnxk_gpio_queue_count,
 };
 
 static int
-- 
2.25.1



[PATCH v2 04/10] raw/cnxk_gpio: support queue setup

2021-11-28 Thread Tomasz Duszynski
Add support for queue setup.

Signed-off-by: Tomasz Duszynski 
---
 drivers/raw/cnxk_gpio/cnxk_gpio.c | 80 +++
 1 file changed, 80 insertions(+)

diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index 84be7f861e..98b5dd9cd8 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -134,6 +134,85 @@ cnxk_gpio_read_attr_int(char *attr, int *val)
return 0;
 }
 
+static int
+cnxk_gpio_write_attr(const char *attr, const char *val)
+{
+   FILE *fp;
+   int ret;
+
+   if (!val)
+   return -EINVAL;
+
+   fp = fopen(attr, "w");
+   if (!fp)
+   return -errno;
+
+   ret = fprintf(fp, "%s", val);
+   if (ret < 0) {
+   fclose(fp);
+   return ret;
+   }
+
+   ret = fclose(fp);
+   if (ret)
+   return -errno;
+
+   return 0;
+}
+
+static int
+cnxk_gpio_write_attr_int(const char *attr, int val)
+{
+   char buf[CNXK_GPIO_BUFSZ];
+
+   snprintf(buf, sizeof(buf), "%d", val);
+
+   return cnxk_gpio_write_attr(attr, buf);
+}
+
+static struct cnxk_gpio *
+cnxk_gpio_lookup(struct cnxk_gpiochip *gpiochip, uint16_t queue)
+{
+   if (queue >= gpiochip->num_gpios)
+   return NULL;
+
+   return gpiochip->gpios[queue];
+}
+
+static int
+cnxk_gpio_queue_setup(struct rte_rawdev *dev, uint16_t queue_id,
+ rte_rawdev_obj_t queue_conf, size_t queue_conf_size)
+{
+   struct cnxk_gpiochip *gpiochip = dev->dev_private;
+   char buf[CNXK_GPIO_BUFSZ];
+   struct cnxk_gpio *gpio;
+   int ret;
+
+   RTE_SET_USED(queue_conf);
+   RTE_SET_USED(queue_conf_size);
+
+   gpio = cnxk_gpio_lookup(gpiochip, queue_id);
+   if (gpio)
+   return -EEXIST;
+
+   gpio = rte_zmalloc(NULL, sizeof(*gpio), 0);
+   if (!gpio)
+   return -ENOMEM;
+   gpio->num = queue_id + gpiochip->base;
+   gpio->gpiochip = gpiochip;
+
+   snprintf(buf, sizeof(buf), "%s/export", CNXK_GPIO_CLASS_PATH);
+   ret = cnxk_gpio_write_attr_int(buf, gpio->num);
+   if (ret) {
+   rte_free(gpio);
+   return ret;
+   }
+
+   gpiochip->gpios[queue_id] = gpio;
+
+   return 0;
+}
+
 static int
 cnxk_gpio_queue_def_conf(struct rte_rawdev *dev, uint16_t queue_id,
 rte_rawdev_obj_t queue_conf, size_t queue_conf_size)
@@ -163,6 +242,7 @@ cnxk_gpio_queue_count(struct rte_rawdev *dev)
 static const struct rte_rawdev_ops cnxk_gpio_rawdev_ops = {
.queue_def_conf = cnxk_gpio_queue_def_conf,
.queue_count = cnxk_gpio_queue_count,
+   .queue_setup = cnxk_gpio_queue_setup,
 };
 
 static int
-- 
2.25.1



[PATCH v2 05/10] raw/cnxk_gpio: support queue release

2021-11-28 Thread Tomasz Duszynski
Add support for queue release.

Signed-off-by: Tomasz Duszynski 
---
 drivers/raw/cnxk_gpio/cnxk_gpio.c | 34 +++
 1 file changed, 34 insertions(+)

diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index 98b5dd9cd8..8ac3c5e1be 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -213,6 +213,29 @@ cnxk_gpio_queue_setup(struct rte_rawdev *dev, uint16_t 
queue_id,
return 0;
 }
 
+static int
+cnxk_gpio_queue_release(struct rte_rawdev *dev, uint16_t queue_id)
+{
+   struct cnxk_gpiochip *gpiochip = dev->dev_private;
+   char buf[CNXK_GPIO_BUFSZ];
+   struct cnxk_gpio *gpio;
+   int ret;
+
+   gpio = cnxk_gpio_lookup(gpiochip, queue_id);
+   if (!gpio)
+   return -ENODEV;
+
+   snprintf(buf, sizeof(buf), "%s/unexport", CNXK_GPIO_CLASS_PATH);
+   ret = cnxk_gpio_write_attr_int(buf, gpiochip->base + queue_id);
+   if (ret)
+   return ret;
+
+   gpiochip->gpios[queue_id] = NULL;
+   rte_free(gpio);
+
+   return 0;
+}
+
 static int
 cnxk_gpio_queue_def_conf(struct rte_rawdev *dev, uint16_t queue_id,
 rte_rawdev_obj_t queue_conf, size_t queue_conf_size)
@@ -243,6 +266,7 @@ static const struct rte_rawdev_ops cnxk_gpio_rawdev_ops = {
.queue_def_conf = cnxk_gpio_queue_def_conf,
.queue_count = cnxk_gpio_queue_count,
.queue_setup = cnxk_gpio_queue_setup,
+   .queue_release = cnxk_gpio_queue_release,
 };
 
 static int
@@ -316,6 +340,8 @@ cnxk_gpio_remove(struct rte_vdev_device *dev)
char name[RTE_RAWDEV_NAME_MAX_LEN];
struct cnxk_gpiochip *gpiochip;
struct rte_rawdev *rawdev;
+   struct cnxk_gpio *gpio;
+   int i;
 
RTE_SET_USED(dev);
 
@@ -328,6 +354,14 @@ cnxk_gpio_remove(struct rte_vdev_device *dev)
return -ENODEV;
 
gpiochip = rawdev->dev_private;
+   for (i = 0; i < gpiochip->num_gpios; i++) {
+   gpio = gpiochip->gpios[i];
+   if (!gpio)
+   continue;
+
+   cnxk_gpio_queue_release(rawdev, gpio->num);
+   }
+
rte_free(gpiochip->gpios);
rte_rawdev_pmd_release(rawdev);
 
-- 
2.25.1



[PATCH v2 06/10] raw/cnxk_gpio: support enqueuing buffers

2021-11-28 Thread Tomasz Duszynski
Add dummy support for enqueuing buffers.

Signed-off-by: Tomasz Duszynski 
---
 drivers/raw/cnxk_gpio/cnxk_gpio.c | 46 +++
 drivers/raw/cnxk_gpio/cnxk_gpio.h |  1 +
 drivers/raw/cnxk_gpio/meson.build |  1 +
 drivers/raw/cnxk_gpio/rte_pmd_cnxk_gpio.h | 38 +++
 4 files changed, 86 insertions(+)
 create mode 100644 drivers/raw/cnxk_gpio/rte_pmd_cnxk_gpio.h

diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index 8ac3c5e1be..c08ccdfbb8 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -14,6 +14,7 @@
 #include 
 
 #include "cnxk_gpio.h"
+#include "rte_pmd_cnxk_gpio.h"
 
 #define CNXK_GPIO_BUFSZ 128
 #define CNXK_GPIO_CLASS_PATH "/sys/class/gpio"
@@ -262,7 +263,52 @@ cnxk_gpio_queue_count(struct rte_rawdev *dev)
return gpiochip->num_gpios;
 }
 
+static int
+cnxk_gpio_process_buf(struct cnxk_gpio *gpio, struct rte_rawdev_buf *rbuf)
+{
+   struct cnxk_gpio_msg *msg = rbuf->buf_addr;
+   void *rsp = NULL;
+
+   switch (msg->type) {
+   default:
+   return -EINVAL;
+   }
+
+   /* get rid of last response if any */
+   if (gpio->rsp) {
+   RTE_LOG(WARNING, PMD, "previous response got overwritten\n");
+   rte_free(gpio->rsp);
+   }
+   gpio->rsp = rsp;
+
+   return 0;
+}
+
+static int
+cnxk_gpio_enqueue_bufs(struct rte_rawdev *dev, struct rte_rawdev_buf **buffers,
+  unsigned int count, rte_rawdev_obj_t context)
+{
+   struct cnxk_gpiochip *gpiochip = dev->dev_private;
+   unsigned int queue = (size_t)context;
+   struct cnxk_gpio *gpio;
+   int ret;
+
+   if (count == 0)
+   return 0;
+
+   gpio = cnxk_gpio_lookup(gpiochip, queue);
+   if (!gpio)
+   return -ENODEV;
+
+   ret = cnxk_gpio_process_buf(gpio, buffers[0]);
+   if (ret)
+   return ret;
+
+   return 1;
+}
+
 static const struct rte_rawdev_ops cnxk_gpio_rawdev_ops = {
+   .enqueue_bufs = cnxk_gpio_enqueue_bufs,
.queue_def_conf = cnxk_gpio_queue_def_conf,
.queue_count = cnxk_gpio_queue_count,
.queue_setup = cnxk_gpio_queue_setup,
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.h 
b/drivers/raw/cnxk_gpio/cnxk_gpio.h
index 4dae8316ba..6b54ebe6e6 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.h
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.h
@@ -9,6 +9,7 @@ struct cnxk_gpiochip;
 
 struct cnxk_gpio {
struct cnxk_gpiochip *gpiochip;
+   void *rsp;
int num;
 };
 
diff --git a/drivers/raw/cnxk_gpio/meson.build 
b/drivers/raw/cnxk_gpio/meson.build
index 9a7e716c1e..3fbfdd838c 100644
--- a/drivers/raw/cnxk_gpio/meson.build
+++ b/drivers/raw/cnxk_gpio/meson.build
@@ -6,3 +6,4 @@ deps += ['bus_vdev', 'common_cnxk', 'rawdev', 'kvargs']
 sources = files(
 'cnxk_gpio.c',
 )
+headers = files('rte_pmd_cnxk_gpio.h')
diff --git a/drivers/raw/cnxk_gpio/rte_pmd_cnxk_gpio.h 
b/drivers/raw/cnxk_gpio/rte_pmd_cnxk_gpio.h
new file mode 100644
index 00..c71065e10c
--- /dev/null
+++ b/drivers/raw/cnxk_gpio/rte_pmd_cnxk_gpio.h
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#ifndef _RTE_PMD_CNXK_GPIO_H_
+#define _RTE_PMD_CNXK_GPIO_H_
+
+/**
+ * @file rte_pmd_cnxk_gpio.h
+ *
+ * Marvell GPIO PMD specific structures and interface
+ *
+ * This API allows applications to manage GPIOs in user space along with
+ * installing interrupt handlers for low latency signal processing.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Available message types */
+enum cnxk_gpio_msg_type {
+   /** Invalid message type */
+   CNXK_GPIO_MSG_TYPE_INVALID,
+};
+
+struct cnxk_gpio_msg {
+   /** Message type */
+   enum cnxk_gpio_msg_type type;
+   /** Message data passed to PMD or received from PMD */
+   void *data;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_PMD_CNXK_GPIO_H_ */
-- 
2.25.1



[PATCH v2 07/10] raw/cnxk_gpio: support dequeuing buffers

2021-11-28 Thread Tomasz Duszynski
Add support for dequeuing buffers.

Signed-off-by: Tomasz Duszynski 
---
 drivers/raw/cnxk_gpio/cnxk_gpio.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index c08ccdfbb8..244a625822 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -307,8 +307,34 @@ cnxk_gpio_enqueue_bufs(struct rte_rawdev *dev, struct 
rte_rawdev_buf **buffers,
return 1;
 }
 
+static int
+cnxk_gpio_dequeue_bufs(struct rte_rawdev *dev, struct rte_rawdev_buf **buffers,
+  unsigned int count, rte_rawdev_obj_t context)
+{
+   struct cnxk_gpiochip *gpiochip = dev->dev_private;
+   unsigned int queue = (size_t)context;
+   struct cnxk_gpio *gpio;
+
+   if (count == 0)
+   return 0;
+
+   gpio = cnxk_gpio_lookup(gpiochip, queue);
+   if (!gpio)
+   return -ENODEV;
+
+   if (gpio->rsp) {
+   buffers[0]->buf_addr = gpio->rsp;
+   gpio->rsp = NULL;
+
+   return 1;
+   }
+
+   return 0;
+}
+
 static const struct rte_rawdev_ops cnxk_gpio_rawdev_ops = {
.enqueue_bufs = cnxk_gpio_enqueue_bufs,
+   .dequeue_bufs = cnxk_gpio_dequeue_bufs,
.queue_def_conf = cnxk_gpio_queue_def_conf,
.queue_count = cnxk_gpio_queue_count,
.queue_setup = cnxk_gpio_queue_setup,
-- 
2.25.1



[PATCH v2 08/10] raw/cnxk_gpio: support standard GPIO operations

2021-11-28 Thread Tomasz Duszynski
Add support for standard GPIO operations i.e ones normally
provided by GPIO sysfs interface.

Signed-off-by: Tomasz Duszynski 
---
 doc/guides/rawdevs/cnxk_gpio.rst  |  98 
 drivers/raw/cnxk_gpio/cnxk_gpio.c | 146 +++
 drivers/raw/cnxk_gpio/rte_pmd_cnxk_gpio.h | 279 +-
 3 files changed, 521 insertions(+), 2 deletions(-)

diff --git a/doc/guides/rawdevs/cnxk_gpio.rst b/doc/guides/rawdevs/cnxk_gpio.rst
index 868302d07f..f6c3c942c5 100644
--- a/doc/guides/rawdevs/cnxk_gpio.rst
+++ b/doc/guides/rawdevs/cnxk_gpio.rst
@@ -63,3 +63,101 @@ call barely exports GPIO to userspace.
 To perform actual data transfer use standard ``rte_rawdev_enqueue_buffers()``
 and ``rte_rawdev_dequeue_buffers()`` APIs. Not all messages produce sensible
 responses hence dequeueing is not always necessary.
+
+CNXK GPIO PMD
+-
+
+PMD accepts ``struct cnxk_gpio_msg`` messages which differ by type and payload.
+Message types along with description are listed below. As for the usage 
examples
+please refer to ``cnxk_gpio_selftest()``. There's a set of convenient wrappers
+available, one for each existing command.
+
+Set GPIO value
+~~
+
+Message is used to set output to low or high. This does not work for GPIOs
+configured as input.
+
+Message must have type set to ``CNXK_GPIO_MSG_TYPE_SET_PIN_VALUE``.
+
+Payload must be an integer set to 0 (low) or 1 (high).
+
+Consider using ``rte_pmd_gpio_set_pin_value()`` wrapper.
+
+Set GPIO edge
+~
+
+Message is used to set edge that triggers interrupt.
+
+Message must have type set to ``CNXK_GPIO_MSG_TYPE_SET_PIN_EDGE``.
+
+Payload must be `enum cnxk_gpio_pin_edge`.
+
+Consider using ``rte_pmd_gpio_set_pin_edge()`` wrapper.
+
+Set GPIO direction
+~~
+
+Message is used to change GPIO direction to either input or output.
+
+Message must have type set to ``CNXK_GPIO_MSG_TYPE_SET_PIN_DIR``.
+
+Payload must be `enum cnxk_gpio_pin_dir`.
+
+Consider using ``rte_pmd_gpio_set_pin_dir()`` wrapper.
+
+Set GPIO active low
+~~~
+
+Message is used to set whether pin is active low.
+
+Message must have type set to ``CNXK_GPIO_MSG_TYPE_SET_PIN_ACTIVE_LOW``.
+
+Payload must be an integer set to 0 or 1. The latter activates inversion.
+
+Consider using ``rte_pmd_gpio_set_pin_active_low()`` wrapper.
+
+Get GPIO value
+~~
+
+Message is used to read GPIO value. Value can be 0 (low) or 1 (high).
+
+Message must have type set to ``CNXK_GPIO_MSG_TYPE_GET_PIN_VALUE``.
+
+Payload contains integer set to either 0 or 1.
+
+Consider using ``rte_pmd_gpio_get_pin_value()`` wrapper.
+
+Get GPIO edge
+~
+
+Message is used to read GPIO edge.
+
+Message must have type set to ``CNXK_GPIO_MSG_TYPE_GET_PIN_EDGE``.
+
+Payload contains `enum cnxk_gpio_pin_edge`.
+
+Consider using ``rte_pmd_gpio_get_pin_edge()`` wrapper.
+
+Get GPIO direction
+~~
+
+Message is used to read GPIO direction.
+
+Message must have type set to ``CNXK_GPIO_MSG_TYPE_GET_PIN_DIR``.
+
+Payload contains `enum cnxk_gpio_pin_dir`.
+
+Consider using ``rte_pmd_gpio_get_pin_dir()`` wrapper.
+
+Get GPIO active low
+~~~
+
+Message is used check whether inverted logic is active.
+
+Message must have type set to ``CNXK_GPIO_MSG_TYPE_GET_PIN_ACTIVE_LOW``.
+
+Payload contains an integer set to 0 or 1. The latter means inverted logic
+is turned on.
+
+Consider using ``rte_pmd_gpio_get_pin_active_low()`` wrapper.
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index 244a625822..c09bc5d56e 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -263,13 +263,159 @@ cnxk_gpio_queue_count(struct rte_rawdev *dev)
return gpiochip->num_gpios;
 }
 
+static const struct {
+   enum cnxk_gpio_pin_edge edge;
+   const char *name;
+} cnxk_gpio_edge_name[] = {
+   { CNXK_GPIO_PIN_EDGE_NONE, "none" },
+   { CNXK_GPIO_PIN_EDGE_FALLING, "falling" },
+   { CNXK_GPIO_PIN_EDGE_RISING, "rising" },
+   { CNXK_GPIO_PIN_EDGE_BOTH, "both" },
+};
+
+static const char *
+cnxk_gpio_edge_to_name(enum cnxk_gpio_pin_edge edge)
+{
+   unsigned int i;
+
+   for (i = 0; i < RTE_DIM(cnxk_gpio_edge_name); i++) {
+   if (cnxk_gpio_edge_name[i].edge == edge)
+   return cnxk_gpio_edge_name[i].name;
+   }
+
+   return NULL;
+}
+
+static enum cnxk_gpio_pin_edge
+cnxk_gpio_name_to_edge(const char *name)
+{
+   unsigned int i;
+
+   for (i = 0; i < RTE_DIM(cnxk_gpio_edge_name); i++) {
+   if (!strcmp(cnxk_gpio_edge_name[i].name, name))
+   break;
+   }
+
+   return cnxk_gpio_edge_name[i].edge;
+}
+
+static const struct {
+   enum cnxk_gpio_pin_dir dir;
+   const char *name;
+} cnxk_gpio_dir_name[] = {
+   { CNXK_GPIO_PIN_DIR_IN, "in" },
+   { CNXK_GPIO_PIN_DIR_OUT, "out" },
+   { CNXK_GPIO_PIN_DIR_HIGH, "high" },
+   { CNXK_GPIO_PIN

[PATCH v2 09/10] raw/cnxk_gpio: support custom irq handlers

2021-11-28 Thread Tomasz Duszynski
Add support for custom interrupt handlers. Custom interrupt
handlers bypass kernel completely and are meant for fast
and low latency access to GPIO state.

Signed-off-by: Tomasz Duszynski 
---
 doc/guides/rawdevs/cnxk_gpio.rst  |  21 +++
 drivers/raw/cnxk_gpio/cnxk_gpio.c |  37 
 drivers/raw/cnxk_gpio/cnxk_gpio.h |   8 +
 drivers/raw/cnxk_gpio/cnxk_gpio_irq.c | 216 ++
 drivers/raw/cnxk_gpio/meson.build |   1 +
 drivers/raw/cnxk_gpio/rte_pmd_cnxk_gpio.h | 116 
 6 files changed, 399 insertions(+)
 create mode 100644 drivers/raw/cnxk_gpio/cnxk_gpio_irq.c

diff --git a/doc/guides/rawdevs/cnxk_gpio.rst b/doc/guides/rawdevs/cnxk_gpio.rst
index f6c3c942c5..ad93ec0d44 100644
--- a/doc/guides/rawdevs/cnxk_gpio.rst
+++ b/doc/guides/rawdevs/cnxk_gpio.rst
@@ -161,3 +161,24 @@ Payload contains an integer set to 0 or 1. The latter 
means inverted logic
 is turned on.
 
 Consider using ``rte_pmd_gpio_get_pin_active_low()`` wrapper.
+
+Request interrupt
+~
+
+Message is used to install custom interrupt handler.
+
+Message must have type set to ``CNXK_GPIO_MSG_TYPE_REGISTER_IRQ``.
+
+Payload needs to be set to ``struct cnxk_gpio_irq`` which describes interrupt
+being requested.
+
+Consider using ``rte_pmd_gpio_register_gpio()`` wrapper.
+
+Free interrupt
+~~
+
+Message is used to remove installed interrupt handler.
+
+Message must have type set to ``CNXK_GPIO_MSG_TYPE_UNREGISTER_IRQ``.
+
+Consider using ``rte_pmd_gpio_unregister_gpio()`` wrapper.
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index c09bc5d56e..d39d203245 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -335,6 +335,28 @@ cnxk_gpio_name_to_dir(const char *name)
return cnxk_gpio_dir_name[i].dir;
 }
 
+static int
+cnxk_gpio_register_irq(struct cnxk_gpio *gpio, struct cnxk_gpio_irq *irq)
+{
+   int ret;
+
+   ret = cnxk_gpio_irq_request(gpio->num - gpio->gpiochip->base, irq->cpu);
+   if (ret)
+   return ret;
+
+   gpio->handler = irq->handler;
+   gpio->data = irq->data;
+   gpio->cpu = irq->cpu;
+
+   return 0;
+}
+
+static int
+cnxk_gpio_unregister_irq(struct cnxk_gpio *gpio)
+{
+   return cnxk_gpio_irq_free(gpio->num - gpio->gpiochip->base);
+}
+
 static int
 cnxk_gpio_process_buf(struct cnxk_gpio *gpio, struct rte_rawdev_buf *rbuf)
 {
@@ -416,6 +438,13 @@ cnxk_gpio_process_buf(struct cnxk_gpio *gpio, struct 
rte_rawdev_buf *rbuf)
 
*(int *)rsp = val;
break;
+   case CNXK_GPIO_MSG_TYPE_REGISTER_IRQ:
+   ret = cnxk_gpio_register_irq(gpio,
+(struct cnxk_gpio_irq *)msg->data);
+   break;
+   case CNXK_GPIO_MSG_TYPE_UNREGISTER_IRQ:
+   ret = cnxk_gpio_unregister_irq(gpio);
+   break;
default:
return -EINVAL;
}
@@ -519,6 +548,10 @@ cnxk_gpio_probe(struct rte_vdev_device *dev)
if (ret)
goto out;
 
+   ret = cnxk_gpio_irq_init(gpiochip);
+   if (ret)
+   goto out;
+
/* read gpio base */
snprintf(buf, sizeof(buf), "%s/gpiochip%d/base", CNXK_GPIO_CLASS_PATH,
 gpiochip->num);
@@ -577,10 +610,14 @@ cnxk_gpio_remove(struct rte_vdev_device *dev)
if (!gpio)
continue;
 
+   if (gpio->handler)
+   cnxk_gpio_unregister_irq(gpio);
+
cnxk_gpio_queue_release(rawdev, gpio->num);
}
 
rte_free(gpiochip->gpios);
+   cnxk_gpio_irq_fini();
rte_rawdev_pmd_release(rawdev);
 
return 0;
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.h 
b/drivers/raw/cnxk_gpio/cnxk_gpio.h
index 6b54ebe6e6..c052ca5735 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.h
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.h
@@ -11,6 +11,9 @@ struct cnxk_gpio {
struct cnxk_gpiochip *gpiochip;
void *rsp;
int num;
+   void (*handler)(int gpio, void *data);
+   void *data;
+   int cpu;
 };
 
 struct cnxk_gpiochip {
@@ -20,4 +23,9 @@ struct cnxk_gpiochip {
struct cnxk_gpio **gpios;
 };
 
+int cnxk_gpio_irq_init(struct cnxk_gpiochip *gpiochip);
+void cnxk_gpio_irq_fini(void);
+int cnxk_gpio_irq_request(int gpio, int cpu);
+int cnxk_gpio_irq_free(int gpio);
+
 #endif /* _CNXK_GPIO_H_ */
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio_irq.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio_irq.c
new file mode 100644
index 00..2fa8e69899
--- /dev/null
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio_irq.c
@@ -0,0 +1,216 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#include "cnxk_gpio.h"
+
+#define OTX_IOC_MAGIC 0xF2
+#define OTX_IOC_SET_GPIO_HANDLER   
\
+  

[PATCH v2 10/10] raw/cnxk_gpio: support selftest

2021-11-28 Thread Tomasz Duszynski
Add support for performing selftest.

Signed-off-by: Tomasz Duszynski 
---
 doc/guides/rawdevs/cnxk_gpio.rst   |  11 +
 drivers/raw/cnxk_gpio/cnxk_gpio.c  |   1 +
 drivers/raw/cnxk_gpio/cnxk_gpio.h  |   2 +
 drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c | 386 +
 drivers/raw/cnxk_gpio/meson.build  |   1 +
 5 files changed, 401 insertions(+)
 create mode 100644 drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c

diff --git a/doc/guides/rawdevs/cnxk_gpio.rst b/doc/guides/rawdevs/cnxk_gpio.rst
index ad93ec0d44..c03a5b937c 100644
--- a/doc/guides/rawdevs/cnxk_gpio.rst
+++ b/doc/guides/rawdevs/cnxk_gpio.rst
@@ -182,3 +182,14 @@ Message is used to remove installed interrupt handler.
 Message must have type set to ``CNXK_GPIO_MSG_TYPE_UNREGISTER_IRQ``.
 
 Consider using ``rte_pmd_gpio_unregister_gpio()`` wrapper.
+
+Self test
+-
+
+On EAL initialization CNXK GPIO device will be probed and populated into
+the list of raw devices on condition ``--vdev=cnxk_gpio,gpiochip=`` was
+passed. ``rte_rawdev_get_dev_id("CNXK_GPIO")`` returns unique device id. Use
+this identifier for further rawdev function calls.
+
+Selftest rawdev API can be used to verify the PMD functionality. Note it 
blindly
+assumes that all GPIOs are controllable so some errors during test are 
expected.
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index d39d203245..fa81b45f89 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -514,6 +514,7 @@ static const struct rte_rawdev_ops cnxk_gpio_rawdev_ops = {
.queue_count = cnxk_gpio_queue_count,
.queue_setup = cnxk_gpio_queue_setup,
.queue_release = cnxk_gpio_queue_release,
+   .dev_selftest = cnxk_gpio_selftest,
 };
 
 static int
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.h 
b/drivers/raw/cnxk_gpio/cnxk_gpio.h
index c052ca5735..1b31b5a486 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.h
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.h
@@ -23,6 +23,8 @@ struct cnxk_gpiochip {
struct cnxk_gpio **gpios;
 };
 
+int cnxk_gpio_selftest(uint16_t dev_id);
+
 int cnxk_gpio_irq_init(struct cnxk_gpiochip *gpiochip);
 void cnxk_gpio_irq_fini(void);
 int cnxk_gpio_irq_request(int gpio, int cpu);
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c
new file mode 100644
index 00..6502902f86
--- /dev/null
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c
@@ -0,0 +1,386 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include "cnxk_gpio.h"
+#include "rte_pmd_cnxk_gpio.h"
+
+#define CNXK_GPIO_BUFSZ 128
+
+#define OTX_IOC_MAGIC 0xF2
+#define OTX_IOC_TRIGGER_GPIO_HANDLER   
\
+   _IO(OTX_IOC_MAGIC, 3)
+
+static int fd;
+
+static int
+cnxk_gpio_attr_exists(const char *attr)
+{
+   struct stat st;
+
+   return !stat(attr, &st);
+}
+
+static int
+cnxk_gpio_read_attr(char *attr, char *val)
+{
+   FILE *fp;
+   int ret;
+
+   fp = fopen(attr, "r");
+   if (!fp)
+   return -errno;
+
+   ret = fscanf(fp, "%s", val);
+   if (ret < 0)
+   return -errno;
+   if (ret != 1)
+   return -EIO;
+
+   ret = fclose(fp);
+   if (ret)
+   return -errno;
+
+   return 0;
+}
+
+#define CNXK_GPIO_ERR_STR(err, str, ...) do {  
\
+   if (err) { \
+   RTE_LOG(ERR, PMD, "%s:%d: " str " (%d)\n", __func__, __LINE__, \
+   ##__VA_ARGS__, err);   \
+   goto out;  \
+   }  \
+} while (0)
+
+static int
+cnxk_gpio_validate_attr(char *attr, const char *expected)
+{
+   char buf[CNXK_GPIO_BUFSZ];
+   int ret;
+
+   ret = cnxk_gpio_read_attr(attr, buf);
+   if (ret)
+   return ret;
+
+   if (strncmp(buf, expected, sizeof(buf)))
+   return -EIO;
+
+   return 0;
+}
+
+#define CNXK_GPIO_PATH_FMT "/sys/class/gpio/gpio%d"
+
+static int
+cnxk_gpio_test_input(uint16_t dev_id, int base, int gpio)
+{
+   char buf[CNXK_GPIO_BUFSZ];
+   int ret, n;
+
+   n = snprintf(buf, sizeof(buf), CNXK_GPIO_PATH_FMT, base + gpio);
+   snprintf(buf + n, sizeof(buf) - n, "/direction");
+
+   ret = rte_pmd_gpio_set_pin_dir(dev_id, gpio, CNXK_GPIO_PIN_DIR_IN);
+   CNXK_GPIO_ERR_STR(ret, "failed to set dir to input");
+   ret = cnxk_gpio_validate_attr(buf, "in");
+   CNXK_GPIO_ERR_STR(ret, "failed to validate %s", buf);
+
+   ret = rte_pmd_gpio_set_pin_value(dev_id, gpio, 1) |
+ rte_pmd_gpio_set_pin_value(dev_id, gpio, 0);
+   if (!re

RE: [EXT] |FAILURE| pw104631 [PATCH v2 5/5] regex/cn9k: use cnxk infrastructure

2021-11-28 Thread Liron Himi
Hi,

I have fixed the error below but got additional errors which I need your advice 
if to ignore or update it is some way.
This patch also replace the name of the 'regexdevs/octeontx2' folder to 
'regexdevs/cn9k'
Note that Jerin is going to remove the current 'octeontx2' references as the 
new cnxk is replacing it.

What should I do with those errors:
dpdk-next-net-mrvl/doc/guides/platform/octeontx2.rst:158:unknown document: 
../regexdevs/octeontx2
dpdk-next-net-mrvl/doc/guides/rel_notes/release_20_11.rst:293:unknown document: 
../regexdevs/octeontx2
 

Liron Himi


-Original Message-
From: 0-day Robot  
Sent: Tuesday, 23 November 2021 21:39
To: test-rep...@dpdk.org
Cc: Liron Himi ; ro...@bytheb.org
Subject: [EXT] |FAILURE| pw104631 [PATCH v2 5/5] regex/cn9k: use cnxk 
infrastructure

External Email

--
From: ro...@bytheb.org

Test-Label: github-robot: build
Test-Status: FAILURE
https://urldefense.proofpoint.com/v2/url?u=http-3A__patchwork.dpdk.org_patch_104631_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=M6lEONY3jVnAkBjt0yC6oAsT7Jn2HI7LhNHCQYlnx1Q&m=t5lFxhoB1xIBWU8MMJw2Ye8t3ipEQRRXa1tkPiNY014-j9RG8StvAwgSnKqpi6hn&s=0Bb6lOdxDfbDXDGLguBU0SeNJX8pyNvRPfZm3kkFMwI&e=
 

_github build: failed_
Build URL: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_ovsrobot_dpdk_actions_runs_1496327439&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=M6lEONY3jVnAkBjt0yC6oAsT7Jn2HI7LhNHCQYlnx1Q&m=t5lFxhoB1xIBWU8MMJw2Ye8t3ipEQRRXa1tkPiNY014-j9RG8StvAwgSnKqpi6hn&s=gFlcioDYnxi99XqRR_n9qBCtQH2axCFaqhL_OFd6NOs&e=
Build Logs:
---Summary of failed steps--- 
"ubuntu-18.04-gcc-shared-doc+tests" failed at step Build and test 
"ubuntu-18.04-clang-shared-doc+tests" failed at step Build and test 
--End summary of failed steps

---BEGIN LOGS 

 [Begin job log] "ubuntu-18.04-gcc-shared-doc+tests" at step Build and test 

[3208/3617] Generating 
'buildtools/chkincs/fe389a9@@chkincs@exe/rte_mempool_trace_fp.c'.
[3209/3617] Generating 'buildtools/chkincs/fe389a9@@chkincs@exe/rte_mbuf.c'.
[3210/3617] Generating 
'buildtools/chkincs/fe389a9@@chkincs@exe/rte_mbuf_core.c'.
[3211/3617] Generating 
'buildtools/chkincs/fe389a9@@chkincs@exe/rte_mbuf_ptype.c'.
[3212/3617] Generating 
'buildtools/chkincs/fe389a9@@chkincs@exe/rte_mbuf_pool_ops.c'.
[3213/3617] Generating 'buildtools/chkincs/fe389a9@@chkincs@exe/rte_mbuf_dyn.c'.
[3214/3617] Generating 'buildtools/chkincs/fe389a9@@chkincs@exe/rte_ip.c'.
[3215/3617] Generating 'buildtools/chkincs/fe389a9@@chkincs@exe/rte_tcp.c'.
[3216/3617] Generating 'buildtools/chkincs/fe389a9@@chkincs@exe/rte_udp.c'.
[3217/3617] Generating html_guides with a custom command.
FAILED: doc/guides/html
/usr/bin/python3 ../buildtools/call-sphinx-build.py /usr/bin/sphinx-build 
21.11.0-rc3 /home/runner/work/dpdk/dpdk/doc/guides 
/home/runner/work/dpdk/dpdk/build/doc/guides -W

Warning, treated as error:
/home/runner/work/dpdk/dpdk/doc/guides/regexdevs/cn9k.rst:45:Malformed table.

+---++---+
| # | Component  | EAL log command   |
+===++==
+=+
| 1 | REE| --log-level='pmd\.regex\.cn9k,8' |
+---++---+
[3218/3617] Generating 'buildtools/chkincs/fe389a9@@chkincs@exe/rte_esp.c'.
[3219/3617] Generating 'buildtools/chkincs/fe389a9@@chkincs@exe/rte_sctp.c'.
ninja: build stopped: subcommand failed.
##[error]Process completed with exit code 1.

 [End job log] "ubuntu-18.04-gcc-shared-doc+tests" at step Build and test 






 [Begin job log] "ubuntu-18.04-clang-shared-doc+tests" at step Build and 
test 

[3042/3617] Linking target examples/dpdk-kni.
[3043/3617] Compiling C object 
'examples/c590b3c@@dpdk-l2fwd-event@exe/l2fwd-event_l2fwd_common.c.o'.
[3044/3617] Compiling C object 
'examples/c590b3c@@dpdk-l2fwd@exe/l2fwd_main.c.o'.
[3045/3617] Linking target examples/dpdk-l2fwd.
[3046/3617] Linking target examples/dpdk-l2fwd-crypto.
[3047/3617] Compiling C object 
'examples/c590b3c@@dpdk-l2fwd-event@exe/l2fwd-event_l2fwd_event.c.o'.
[3048/3617] Compiling C object 
'examples/c590b3c@@dpdk-l2fwd-event@exe/l2fwd-event_l2fwd_event_internal_port.c.o'.
[3049/3617] Compiling C object 
'exa

Re: [EXT] |FAILURE| pw104631 [PATCH v2 5/5] regex/cn9k: use cnxk infrastructure

2021-11-28 Thread Thomas Monjalon
28/11/2021 21:17, Liron Himi:
> Hi,
> 
> I have fixed the error below but got additional errors which I need your 
> advice if to ignore or update it is some way.
> This patch also replace the name of the 'regexdevs/octeontx2' folder to 
> 'regexdevs/cn9k'
> Note that Jerin is going to remove the current 'octeontx2' references as the 
> new cnxk is replacing it.
> 
> What should I do with those errors:
> dpdk-next-net-mrvl/doc/guides/platform/octeontx2.rst:158:unknown document: 
> ../regexdevs/octeontx2

This one, you must fix to the next regex doc.

> dpdk-next-net-mrvl/doc/guides/rel_notes/release_20_11.rst:293:unknown 
> document: ../regexdevs/octeontx2

This one, you must replace the link with a normal text.
For instance, this is what was done for another octeontx2 driver:

-  See the :doc:`../rawdevs/octeontx2_ep` for more details on this new PMD.
+  See ``rawdevs/octeontx2_ep`` for more details on this new PMD.





Re: [PATCH v2] kni: fix ioctl signature

2021-11-28 Thread Stephen Hemminger
On Sun, 28 Nov 2021 14:14:26 +0100
Markus Theil  wrote:

> From: Markus Theil 
> 
> Fix kni's ioctl signature to correctly match the kernel's
> structs. This shaves off the (void*) casts and uses struct file*
> instead of struct inode*. With the correct signature, control flow
> integrity checkers are no longer confused at this point.
> 
> Signed-off-by: Markus Theil 
> Tested-by: Michael Pfeiffer 
> ---
> v2: adapt to suggestions from Ferruh Yigit
> 
>  kernel/linux/kni/kni_misc.c | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)

> -static int
> -kni_compat_ioctl(struct inode *inode, uint32_t ioctl_num,
> +static long
> +kni_compat_ioctl(struct file *file, uint32_t ioctl_num,
>   unsigned long ioctl_param)
>  {

Shouldn't be uint32_t should be unsigned int.

In fs.h.

long (*compat_ioctl) (struct file *, unsigned int, unsigned long);