Skip to contentSkip to conversation

Introduce Microsoft Azure Network Adatper (MANA) PMD

PATCH Superseded [email protected] 5 participants 108 messages Sep 3, 2022 – Mar 21, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v7 cover Introduce Microsoft Azure Network Adatper (MANA) PMD

From: Long Li <[email protected]>

MANA is a network interface card to be used in the Azure cloud environment. MANA provides safe access to user memory through memory registration. It has IOMMU built into the hardware.

MANA uses IB verbs and RDMA layer to configure hardware resources. It requires the corresponding RDMA kernel-mode and user-mode drivers.

The MANA RDMA kernel-mode driver is being reviewed at:
https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/

The MANA RDMA user-mode driver is being reviewed at:
https://github.com/linux-rdma/rdma-core/pull/1177

Long Li (18):
net/mana: add basic driver, build environment and doc net/mana: add device configuration and stop net/mana: add function to report support ptypes net/mana: add link update
net/mana: add function for device removal interrupts net/mana: add device info
net/mana: add function to configure RSS net/mana: add function to configure RX queues net/mana: add function to configure TX queues net/mana: implement memory registration net/mana: implement the hardware layer operations net/mana: add function to start/stop TX queues net/mana: add function to start/stop RX queues net/mana: add function to receive packets net/mana: add function to send packets net/mana: add function to start/stop device net/mana: add function to report queue stats net/mana: add function to support RX interrupts

 MAINTAINERS                       |    6 +
 doc/guides/nics/features/mana.ini |   21 +
 doc/guides/nics/index.rst         |    1 +
 doc/guides/nics/mana.rst          |   66 ++
 drivers/net/mana/gdma.c           |  289 ++++++
 drivers/net/mana/mana.c           | 1449 +++++++++++++++++++++++++++++
 drivers/net/mana/mana.h           |  552 +++++++++++
 drivers/net/mana/meson.build      |   48 +
 drivers/net/mana/mp.c             |  323 +++++++
 drivers/net/mana/mr.c             |  324 +++++++
 drivers/net/mana/rx.c             |  519 +++++++++++
 drivers/net/mana/tx.c             |  412 ++++++++
 drivers/net/mana/version.map      |    3 +
 drivers/net/meson.build           |    1 +
 14 files changed, 4014 insertions(+)
 create mode 100644 doc/guides/nics/features/mana.ini
 create mode 100644 doc/guides/nics/mana.rst
 create mode 100644 drivers/net/mana/gdma.c
 create mode 100644 drivers/net/mana/mana.c
 create mode 100644 drivers/net/mana/mana.h
 create mode 100644 drivers/net/mana/meson.build
 create mode 100644 drivers/net/mana/mp.c
 create mode 100644 drivers/net/mana/mr.c
 create mode 100644 drivers/net/mana/rx.c
 create mode 100644 drivers/net/mana/tx.c
 create mode 100644 drivers/net/mana/version.map
Signature · 1 line
2.17.1
#1 lore raw

PATCH v7 1/18 net/mana: add basic driver, build environment and doc

From: Long Li <[email protected]>

MANA is a PCI device. It uses IB verbs to access hardware through the kernel RDMA layer. This patch introduces build environment and basic device probe functions.

---
Change log:
v2:
Fix typos.
Make the driver build only on x86-64 and Linux.
Remove unused header files.
Change port definition to uint16_t or uint8_t (for IB).
Use getline() in place of fgets() to read and truncate a line. v3:
Add meson build check for required functions from RDMA direct verb header file v4:
Remove extra "\n" in logging code.
Use "r" in place of "rb" in fopen() to read text files.
v7:
Remove RTE_ETH_TX_OFFLOAD_TCP_TSO from offload cap.

 MAINTAINERS                       |   6 +
 doc/guides/nics/features/mana.ini |  10 +
 doc/guides/nics/index.rst         |   1 +
 doc/guides/nics/mana.rst          |  66 +++
 drivers/net/mana/mana.c           | 704 ++++++++++++++++++++++++++++++
 drivers/net/mana/mana.h           | 209 +++++++++
 drivers/net/mana/meson.build      |  44 ++
 drivers/net/mana/mp.c             | 235 ++++++++++
 drivers/net/mana/version.map      |   3 +
 drivers/net/meson.build           |   1 +
 10 files changed, 1279 insertions(+)
 create mode 100644 doc/guides/nics/features/mana.ini
 create mode 100644 doc/guides/nics/mana.rst
 create mode 100644 drivers/net/mana/mana.c
 create mode 100644 drivers/net/mana/mana.h
 create mode 100644 drivers/net/mana/meson.build
 create mode 100644 drivers/net/mana/mp.c
 create mode 100644 drivers/net/mana/version.map
MAINTAINERS +6 -0
index 18d9edaf88..b8bda48a33 100644
@@ -837,6 +837,12 @@ F: buildtools/options-ibverbs-static.sh
 F: doc/guides/nics/mlx5.rst
 F: doc/guides/nics/features/mlx5.ini
 
+Microsoft mana
+M: Long Li <[email protected]>
+F: drivers/net/mana
+F: doc/guides/nics/mana.rst
+F: doc/guides/nics/features/mana.ini
+
 Microsoft vdev_netvsc - EXPERIMENTAL
 M: Matan Azrad <[email protected]>
 F: drivers/net/vdev_netvsc/
doc/guides/nics/features/mana.ini new file +10 -0
new file mode 100644
index 0000000000..b92a27374c
@@ -0,0 +1,10 @@
+;
+; Supported features of the 'mana' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+Multiprocess aware   = Y
+Usage doc            = Y
+x86-64               = Y
doc/guides/nics/index.rst +1 -0
index 1c94caccea..2725d1d9f0 100644
@@ -41,6 +41,7 @@ Network Interface Controller Drivers
     intel_vf
     kni
     liquidio
+    mana
     memif
     mlx4
     mlx5
doc/guides/nics/mana.rst new file +66 -0

66 lines not on this page · raw message

drivers/net/mana/mana.c new file +704 -0

704 lines not on this page · raw message

drivers/net/mana/mana.h new file +209 -0

209 lines not on this page · raw message

drivers/net/mana/meson.build new file +44 -0

44 lines not on this page · raw message

drivers/net/mana/mp.c new file +235 -0

235 lines not on this page · raw message

drivers/net/mana/version.map new file +3 -0
new file mode 100644
index 0000000000..c2e0723b4c
@@ -0,0 +1,3 @@
+DPDK_22 {
+	local: *;
+};
drivers/net/meson.build +1 -0
index 2355d1cde8..0b111a6ebb 100644
@@ -34,6 +34,7 @@ drivers = [
         'ixgbe',
         'kni',
         'liquidio',
+        'mana',
         'memif',
         'mlx4',
         'mlx5',
Signature · 1 line
2.17.1
#2 lore raw

Re: [Patch v7 01/18] net/mana: add basic driver, build environment and doc

Quoted 8 lines · On 9/3/2022 2:40 AM, [email protected] wrote:

From: Long Li <[email protected]>

MANA is a PCI device. It uses IB verbs to access hardware through the kernel RDMA layer. This patch introduces build environment and basic device probe functions.

Quoted 16 lines

---
Change log:
v2:
Fix typos.
Make the driver build only on x86-64 and Linux.
Remove unused header files.
Change port definition to uint16_t or uint8_t (for IB).
Use getline() in place of fgets() to read and truncate a line. v3:
Add meson build check for required functions from RDMA direct verb header file v4:
Remove extra "\n" in logging code.
Use "r" in place of "rb" in fopen() to read text files.
v7:
Remove RTE_ETH_TX_OFFLOAD_TCP_TSO from offload cap.

Can you please check review comments on v4 [1], they seem still valid in this version. I didn't go through other patches, but can you please double check comments on all v4 patches?

[1]
https://inbox.dpdk.org/dev/[email protected]/

#3 lore raw

RE: [Patch v7 01/18] net/mana: add basic driver, build environment and doc

Quoted 31 lines

Subject: Re: [Patch v7 01/18] net/mana: add basic driver, build environment and doc

Quoted 8 lines · On 9/3/2022 2:40 AM, [email protected] wrote:

From: Long Li <[email protected]>

MANA is a PCI device. It uses IB verbs to access hardware through the kernel RDMA layer. This patch introduces build environment and basic device probe functions.

Quoted 17 lines

---
Change log:
v2:
Fix typos.
Make the driver build only on x86-64 and Linux.
Remove unused header files.
Change port definition to uint16_t or uint8_t (for IB). Use getline() in place of fgets() to read and truncate a line. v3:
Add meson build check for required functions from RDMA direct verb header file
v4:
Remove extra "\n" in logging code.
Use "r" in place of "rb" in fopen() to read text files. v7:
Remove RTE_ETH_TX_OFFLOAD_TCP_TSO from offload cap.

Quoted 4 lines

Can you please check review comments on v4 [1], they seem still valid in this version.
I didn't go through other patches, but can you please double check comments on all v4 patches?

Sorry it was an oversight. Will remove all the "\n" and double check.

Quoted 11 lines

[1]
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Finbo
x.dpdk.org%2Fdev%2F859e95d9-2483-b017-6daa- 0852317b4a72%40xilinx.com%2F&amp;data=05%7C01%7Clongli%40microsoft .com%7C85fe7680325e402d210408da9008036c%7C72f988bf86f141af91ab2d7c d011db47%7C1%7C0%7C637980661342767895%7CUnknown%7CTWFpbGZsb3 d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0 %3D%7C3000%7C%7C%7C&amp;sdata=4CHI9uw%2B0MwJtVjamECVZWvUYq BCitq7STstFNPNIN8%3D&amp;reserved=0

#4 lore raw

RE: [Patch v7 01/18] net/mana: add basic driver, build environment and doc

Quoted 34 lines

Subject: RE: [Patch v7 01/18] net/mana: add basic driver, build environment and doc

Quoted 31 lines

Subject: Re: [Patch v7 01/18] net/mana: add basic driver, build environment and doc

Quoted 25 lines · On 9/3/2022 2:40 AM, [email protected] wrote:

From: Long Li <[email protected]>

MANA is a PCI device. It uses IB verbs to access hardware through the kernel RDMA layer. This patch introduces build environment and basic device probe functions.

---
Change log:
v2:
Fix typos.
Make the driver build only on x86-64 and Linux.
Remove unused header files.
Change port definition to uint16_t or uint8_t (for IB). Use getline() in place of fgets() to read and truncate a line. v3:
Add meson build check for required functions from RDMA direct verb header file
v4:
Remove extra "\n" in logging code.
Use "r" in place of "rb" in fopen() to read text files. v7:
Remove RTE_ETH_TX_OFFLOAD_TCP_TSO from offload cap.

Quoted 6 lines
Quoted 4 lines

Can you please check review comments on v4 [1], they seem still valid in this version.
I didn't go through other patches, but can you please double check comments on all v4 patches?

Sorry it was an oversight. Will remove all the "\n" and double check.

Are you referring to " Remove extra "\n" in logging code." In the comment?

There are two places "\n" are used, DRV_LOG() and PMD_INIT_LOG() in mana.h. I think they are okay as there is a single "\n" on each output line.

Please let me know if I missed anything.

Quoted 18 lines
Quoted 5 lines

[1]

https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Finbo

Quoted 2 lines

x.dpdk.org%2Fdev%2F859e95d9-2483-b017-6daa-

0852317b4a72%40xilinx.com%2F&amp;data=05%7C01%7Clongli%40microsoft

Quoted 1 line

.com%7C85fe7680325e402d210408da9008036c%7C72f988bf86f141af91ab2d

7c

Quoted 1 line

d011db47%7C1%7C0%7C637980661342767895%7CUnknown%7CTWFpbGZsb3

Quoted 1 line

d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0

Quoted 1 line

%3D%7C3000%7C%7C%7C&amp;sdata=4CHI9uw%2B0MwJtVjamECVZWvU

Yq

Quoted 1 line

BCitq7STstFNPNIN8%3D&amp;reserved=0

#5 lore raw

Re: [Patch v7 01/18] net/mana: add basic driver, build environment and doc

Quoted 40 lines · Long Li
Quoted 40 lines

Subject: RE: [Patch v7 01/18] net/mana: add basic driver, build environment and doc

Quoted 35 lines

Subject: Re: [Patch v7 01/18] net/mana: add basic driver, build environment and doc

Quoted 8 lines · On 9/3/2022 2:40 AM, [email protected] wrote:

From: Long Li <[email protected]>

MANA is a PCI device. It uses IB verbs to access hardware through the kernel RDMA layer. This patch introduces build environment and basic device probe functions.

Quoted 17 lines

---
Change log:
v2:
Fix typos.
Make the driver build only on x86-64 and Linux.
Remove unused header files.
Change port definition to uint16_t or uint8_t (for IB). Use getline() in place of fgets() to read and truncate a line. v3:
Add meson build check for required functions from RDMA direct verb header file
v4:
Remove extra "\n" in logging code.
Use "r" in place of "rb" in fopen() to read text files. v7:
Remove RTE_ETH_TX_OFFLOAD_TCP_TSO from offload cap.

Can you please check review comments on v4 [1], they seem still valid in this version.
I didn't go through other patches, but can you please double check comments on all v4 patches?

Quoted 8 lines
Quoted 1 line

Sorry it was an oversight. Will remove all the "\n" and double check.

Are you referring to " Remove extra "\n" in logging code." In the comment?

There are two places "\n" are used, DRV_LOG() and PMD_INIT_LOG() in mana.h. I think they are okay as there is a single "\n" on each output line.

Please let me know if I missed anything.

Not referring specific to '\n', there are multiple comments there. Can you please double check the email or archive link, comments are all inline?

https://inbox.dpdk.org/dev/[email protected]/

Quoted 19 lines
Quoted 18 lines
Quoted 5 lines

[1]

https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Finbo

Quoted 2 lines

x.dpdk.org%2Fdev%2F859e95d9-2483-b017-6daa-

0852317b4a72%40xilinx.com%2F&amp;data=05%7C01%7Clongli%40microsoft

Quoted 1 line

.com%7C85fe7680325e402d210408da9008036c%7C72f988bf86f141af91ab2d

7c

Quoted 1 line

d011db47%7C1%7C0%7C637980661342767895%7CUnknown%7CTWFpbGZsb3

Quoted 1 line

d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0

Quoted 1 line

%3D%7C3000%7C%7C%7C&amp;sdata=4CHI9uw%2B0MwJtVjamECVZWvU

Yq

Quoted 1 line

BCitq7STstFNPNIN8%3D&amp;reserved=0

#6 lore raw

RE: [Patch v7 01/18] net/mana: add basic driver, build environment and doc

Quoted 49 lines

Subject: Re: [Patch v7 01/18] net/mana: add basic driver, build environment and doc

Quoted 44 lines · Long Li
Quoted 35 lines

Subject: RE: [Patch v7 01/18] net/mana: add basic driver, build environment and doc

Quoted 31 lines

Subject: Re: [Patch v7 01/18] net/mana: add basic driver, build environment and doc

Quoted 25 lines · On 9/3/2022 2:40 AM, [email protected] wrote:

From: Long Li <[email protected]>

MANA is a PCI device. It uses IB verbs to access hardware through the kernel RDMA layer. This patch introduces build environment and basic device probe functions.

---
Change log:
v2:
Fix typos.
Make the driver build only on x86-64 and Linux.
Remove unused header files.
Change port definition to uint16_t or uint8_t (for IB). Use getline() in place of fgets() to read and truncate a line. v3:
Add meson build check for required functions from RDMA direct verb header file
v4:
Remove extra "\n" in logging code.
Use "r" in place of "rb" in fopen() to read text files. v7:
Remove RTE_ETH_TX_OFFLOAD_TCP_TSO from offload cap.

Quoted 6 lines
Quoted 4 lines

Can you please check review comments on v4 [1], they seem still valid in this version.
I didn't go through other patches, but can you please double check comments on all v4 patches?

Sorry it was an oversight. Will remove all the "\n" and double check.

Are you referring to " Remove extra "\n" in logging code." In the comment?

Quoted 8 lines
Quoted 1 line

There are two places "\n" are used, DRV_LOG() and PMD_INIT_LOG() in

mana.h. I think they are okay as there is a single "\n" on each output line.

Quoted 3 lines

Please let me know if I missed anything.

Not referring specific to '\n', there are multiple comments there. Can you please double check the email or archive link, comments are all inline?

I apologize I have missed some of the comments. I will address those and send next version.

Quoted 36 lines

https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Finbo
x.dpdk.org%2Fdev%2F859e95d9-2483-b017-6daa- 0852317b4a72%40xilinx.com%2F&amp;data=05%7C01%7Clongli%40microsoft .com%7Cf92fcbd63c2e47b00aed08da90b11cc8%7C72f988bf86f141af91ab2d7c d011db47%7C1%7C0%7C637981387628427454%7CUnknown%7CTWFpbGZsb3 d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0 %3D%7C3000%7C%7C%7C&amp;sdata=g1dkWTofo%2FD40ANMkI09jpyHp8Q UEtCoRTCff1mrPEs%3D&amp;reserved=0

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

[1]

https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Finb

Quoted 4 lines
Quoted 4 lines

o

Quoted 2 lines

x.dpdk.org%2Fdev%2F859e95d9-2483-b017-6daa-

0852317b4a72%40xilinx.com%2F&amp;data=05%7C01%7Clongli%40microsoft

Quoted 1 line
Quoted 1 line
Quoted 1 line

.com%7C85fe7680325e402d210408da9008036c%7C72f988bf86f141af91ab

2d

Quoted 3 lines
Quoted 3 lines

7c

Quoted 1 line

d011db47%7C1%7C0%7C637980661342767895%7CUnknown%7CTWFpbGZsb3

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0

Quoted 1 line
Quoted 1 line
Quoted 1 line

%3D%7C3000%7C%7C%7C&amp;sdata=4CHI9uw%2B0MwJtVjamECVZW

vU

Quoted 3 lines
Quoted 2 lines

Yq

Quoted 1 line

BCitq7STstFNPNIN8%3D&amp;reserved=0

#7 lore raw

Re: [Patch v7 01/18] net/mana: add basic driver, build environment and doc

In reply to [email protected]
Quoted 8 lines · On Fri, 2 Sep 2022 18:40:43 -0700 [email protected] wrote:

From: Long Li <[email protected]>

MANA is a PCI device. It uses IB verbs to access hardware through the kernel RDMA layer. This patch introduces build environment and basic device probe functions.

---

You should add a reference to minimal required version of rdma-core. Older versions won't work right.

#8 lore raw

RE: [Patch v7 01/18] net/mana: add basic driver, build environment and doc

Quoted 12 lines

Subject: Re: [Patch v7 01/18] net/mana: add basic driver, build environment and doc

Quoted 6 lines · On Fri, 2 Sep 2022 18:40:43 -0700 [email protected] wrote:

From: Long Li <[email protected]>

MANA is a PCI device. It uses IB verbs to access hardware through the kernel RDMA layer. This patch introduces build environment and basic device probe functions.

Quoted 5 lines
Quoted 2 lines

---

You should add a reference to minimal required version of rdma-core. Older versions won't work right.

I'm adding a reference to build requirement in doc/guides/nics/mana.rst.

"drivers/net/mana/meson.build" has a build dependency on libmana from rdma-core. It won't build on older versions of rdma-core.

#9 lore raw

Re: [Patch v7 01/18] net/mana: add basic driver, build environment and doc

Quoted 15 lines · Long Li
Quoted 15 lines

Subject: Re: [Patch v7 01/18] net/mana: add basic driver, build environment and doc

Quoted 8 lines · On Fri, 2 Sep 2022 18:40:43 -0700 [email protected] wrote:

From: Long Li <[email protected]>

MANA is a PCI device. It uses IB verbs to access hardware through the kernel RDMA layer. This patch introduces build environment and basic device probe functions.

---

Quoted 6 lines
Quoted 2 lines

You should add a reference to minimal required version of rdma-core. Older versions won't work right.

I'm adding a reference to build requirement in doc/guides/nics/mana.rst.

"drivers/net/mana/meson.build" has a build dependency on libmana from rdma-core. It won't build on older versions of rdma-core.

It is better to add specific version information that has support, "older/newer" are relative and vague.

#10 lore raw

PATCH v8 1/18 net/mana: add basic driver with build environment and doc

In reply to [email protected]

From: Long Li <[email protected]>

MANA is a PCI device. It uses IB verbs to access hardware through the kernel RDMA layer. This patch introduces build environment and basic device probe functions.

---
Change log:
v2:
Fix typos.
Make the driver build only on x86-64 and Linux.
Remove unused header files.
Change port definition to uint16_t or uint8_t (for IB).
Use getline() in place of fgets() to read and truncate a line. v3:
Add meson build check for required functions from RDMA direct verb header file v4:
Remove extra "\n" in logging code.
Use "r" in place of "rb" in fopen() to read text files.
v7:
Remove RTE_ETH_TX_OFFLOAD_TCP_TSO from offload cap.
v8:
Add clarification on driver args usage to nics guide.
Fix coding sytle on function definitions.
Use different variable names in MANA_MKSTR.
Use MANA_ prefix for all macros.
Use RTE_PMD_REGISTER_PCI in place of rte_pci_register.
Add .vendor_id = 0 to the end of PCI table.
Remove RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS from dev_flags.

 MAINTAINERS                       |   6 +
 doc/guides/nics/features/mana.ini |  10 +
 doc/guides/nics/index.rst         |   1 +
 doc/guides/nics/mana.rst          |  69 +++
 drivers/net/mana/mana.c           | 728 ++++++++++++++++++++++++++++++
 drivers/net/mana/mana.h           | 207 +++++++++
 drivers/net/mana/meson.build      |  44 ++
 drivers/net/mana/mp.c             | 241 ++++++++++
 drivers/net/mana/version.map      |   3 +
 drivers/net/meson.build           |   1 +
 10 files changed, 1310 insertions(+)
 create mode 100644 doc/guides/nics/features/mana.ini
 create mode 100644 doc/guides/nics/mana.rst
 create mode 100644 drivers/net/mana/mana.c
 create mode 100644 drivers/net/mana/mana.h
 create mode 100644 drivers/net/mana/meson.build
 create mode 100644 drivers/net/mana/mp.c
 create mode 100644 drivers/net/mana/version.map
MAINTAINERS +6 -0
index 18d9edaf88..b8bda48a33 100644
@@ -837,6 +837,12 @@ F: buildtools/options-ibverbs-static.sh
 F: doc/guides/nics/mlx5.rst
 F: doc/guides/nics/features/mlx5.ini
 
+Microsoft mana
+M: Long Li <[email protected]>
+F: drivers/net/mana
+F: doc/guides/nics/mana.rst
+F: doc/guides/nics/features/mana.ini
+
 Microsoft vdev_netvsc - EXPERIMENTAL
 M: Matan Azrad <[email protected]>
 F: drivers/net/vdev_netvsc/
doc/guides/nics/features/mana.ini new file +10 -0
new file mode 100644
index 0000000000..b92a27374c
@@ -0,0 +1,10 @@
+;
+; Supported features of the 'mana' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+Multiprocess aware   = Y
+Usage doc            = Y
+x86-64               = Y
doc/guides/nics/index.rst +1 -0
index 1c94caccea..2725d1d9f0 100644
@@ -41,6 +41,7 @@ Network Interface Controller Drivers
     intel_vf
     kni
     liquidio
+    mana
     memif
     mlx4
     mlx5
doc/guides/nics/mana.rst new file +69 -0

69 lines not on this page · raw message

drivers/net/mana/mana.c new file +728 -0

728 lines not on this page · raw message

drivers/net/mana/mana.h new file +207 -0

207 lines not on this page · raw message

drivers/net/mana/meson.build new file +44 -0

44 lines not on this page · raw message

drivers/net/mana/mp.c new file +241 -0

241 lines not on this page · raw message

drivers/net/mana/version.map new file +3 -0
new file mode 100644
index 0000000000..78c3585d7c
@@ -0,0 +1,3 @@
+DPDK_23 {
+	local: *;
+};
drivers/net/meson.build +1 -0
index 2355d1cde8..0b111a6ebb 100644
@@ -34,6 +34,7 @@ drivers = [
         'ixgbe',
         'kni',
         'liquidio',
+        'mana',
         'memif',
         'mlx4',
         'mlx5',
Signature · 1 line
2.17.1
#11 lore raw

Re: [Patch v8 01/18] net/mana: add basic driver with build environment and doc

Quoted 31 lines · On 9/8/2022 10:56 PM, [email protected] wrote:

From: Long Li <[email protected]>

MANA is a PCI device. It uses IB verbs to access hardware through the kernel RDMA layer. This patch introduces build environment and basic device probe functions.

---
Change log:
v2:
Fix typos.
Make the driver build only on x86-64 and Linux.
Remove unused header files.
Change port definition to uint16_t or uint8_t (for IB).
Use getline() in place of fgets() to read and truncate a line. v3:
Add meson build check for required functions from RDMA direct verb header file v4:
Remove extra "\n" in logging code.
Use "r" in place of "rb" in fopen() to read text files.
v7:
Remove RTE_ETH_TX_OFFLOAD_TCP_TSO from offload cap.
v8:
Add clarification on driver args usage to nics guide.
Fix coding sytle on function definitions.
Use different variable names in MANA_MKSTR.
Use MANA_ prefix for all macros.
Use RTE_PMD_REGISTER_PCI in place of rte_pci_register.
Add .vendor_id = 0 to the end of PCI table.
Remove RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS from dev_flags.

<...>

Quoted 26 lines
doc/guides/nics/mana.rst new file +26 -0
+Prerequisites
+-------------
+
+This driver relies on external libraries and kernel drivers for resources
+allocations and initialization. The following dependencies are not part of
+DPDK and must be installed separately:
+
+- **libibverbs** (provided by rdma-core package)
+
+  User space verbs framework used by librte_net_mana. This library provides
+  a generic interface between the kernel and low-level user space drivers
+  such as libmana.
+
+  It allows slow and privileged operations (context initialization, hardware
+  resources allocations) to be managed by the kernel and fast operations to
+  never leave user space.
+
+- **libmana** (provided by rdma-core package)
+
+  Low-level user space driver library for Microsoft Azure Network Adapter
+  devices, it is automatically loaded by libibverbs. The minimal version of
+  rdma-core with libmana is v43.
+
+- **Kernel modules**
+
+  They provide the kernel-side verbs API and low level device drivers that

doc/guides/nics/mana.rst line 50

Quoted 10 lines
doc/guides/nics/mana.rst new file +10 -0
+  manage actual hardware initialization and resources sharing with user
+  space processes.
+
+  Unlike most other PMDs, these modules must remain loaded and bound to
+  their devices:
+
+  - mana: Ethernet device driver that provides kernel network interfaces.
+  - mana_ib: InifiniBand device driver.
+  - ib_uverbs: user space driver for verbs (entry point for libibverbs).
+

Can you please add minimum required versions of kernel and libibverbs (if it applies)?

<...>

drivers/net/mana/mana.c line 717

Quoted 5 lines
drivers/net/mana/mana.c new file +5 -0
+
+static struct rte_pci_driver mana_pci_driver = {
+	.driver = {
+		.name = "net_mana",
+	},

No need to set .driver.name, 'RTE_PMD_REGISTER_PCI' macro below should be setting it already, can you please check?

<...>

drivers/net/mana/mana.h line 37

Quoted 6 lines
drivers/net/mana/mana.h new file +6 -0
+#define MANA_DEV_TX_OFFLOAD_SUPPORT ( \
+		RTE_ETH_TX_OFFLOAD_MULTI_SEGS | \
+		RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | \
+		RTE_ETH_TX_OFFLOAD_TCP_CKSUM | \
+		RTE_ETH_TX_OFFLOAD_UDP_CKSUM)
+

Can you please add code when they are used, instead of batch adding the header, this helps to keep all patches as logical entities.

This comment is valid for multiple code below.

#12 lore raw

RE: [Patch v8 01/18] net/mana: add basic driver with build environment and doc

Quoted 102 lines

Subject: Re: [Patch v8 01/18] net/mana: add basic driver with build environment and doc

Quoted 32 lines · On 9/8/2022 10:56 PM, [email protected] wrote:

From: Long Li <[email protected]>

MANA is a PCI device. It uses IB verbs to access hardware through the kernel RDMA layer. This patch introduces build environment and basic device probe functions.

---
Change log:
v2:
Fix typos.
Make the driver build only on x86-64 and Linux.
Remove unused header files.
Change port definition to uint16_t or uint8_t (for IB). Use getline() in place of fgets() to read and truncate a line. v3:
Add meson build check for required functions from RDMA direct verb header file
v4:
Remove extra "\n" in logging code.
Use "r" in place of "rb" in fopen() to read text files. v7:
Remove RTE_ETH_TX_OFFLOAD_TCP_TSO from offload cap.
v8:
Add clarification on driver args usage to nics guide. Fix coding sytle on function definitions.
Use different variable names in MANA_MKSTR.
Use MANA_ prefix for all macros.
Use RTE_PMD_REGISTER_PCI in place of rte_pci_register. Add .vendor_id = 0 to the end of PCI table.
Remove RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS from dev_flags.

<...>

Quoted 26 lines
doc/guides/nics/mana.rst new file +26 -0
+Prerequisites
+-------------
+
+This driver relies on external libraries and kernel drivers for
+resources allocations and initialization. The following dependencies
+are not part of DPDK and must be installed separately:
+
+- **libibverbs** (provided by rdma-core package)
+
+  User space verbs framework used by librte_net_mana. This library
+ provides  a generic interface between the kernel and low-level user
+ space drivers  such as libmana.
+
+  It allows slow and privileged operations (context initialization,
+ hardware  resources allocations) to be managed by the kernel and
+ fast operations to  never leave user space.
+
+- **libmana** (provided by rdma-core package)
+
+  Low-level user space driver library for Microsoft Azure Network
+ Adapter  devices, it is automatically loaded by libibverbs. The
+ minimal version of  rdma-core with libmana is v43.
+
+- **Kernel modules**
+
+  They provide the kernel-side verbs API and low level device drivers

doc/guides/nics/mana.rst line 50

Quoted 10 lines
doc/guides/nics/mana.rst new file +10 -0
+ that  manage actual hardware initialization and resources sharing
+ with user  space processes.
+
+  Unlike most other PMDs, these modules must remain loaded and bound
+ to  their devices:
+
+  - mana: Ethernet device driver that provides kernel network interfaces.
+  - mana_ib: InifiniBand device driver.
+  - ib_uverbs: user space driver for verbs (entry point for libibverbs).
+

Can you please add minimum required versions of kernel and libibverbs (if it applies)?

<...>

drivers/net/mana/mana.c line 717

Quoted 5 lines
drivers/net/mana/mana.c new file +5 -0
+
+static struct rte_pci_driver mana_pci_driver = {
+	.driver = {
+		.name = "net_mana",
+	},

No need to set .driver.name, 'RTE_PMD_REGISTER_PCI' macro below should be setting it already, can you please check?

<...>

drivers/net/mana/mana.h line 37

Quoted 6 lines
drivers/net/mana/mana.h new file +6 -0
+#define MANA_DEV_TX_OFFLOAD_SUPPORT ( \
+		RTE_ETH_TX_OFFLOAD_MULTI_SEGS | \
+		RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | \
+		RTE_ETH_TX_OFFLOAD_TCP_CKSUM | \
+		RTE_ETH_TX_OFFLOAD_UDP_CKSUM)
+

Can you please add code when they are used, instead of batch adding the header, this helps to keep all patches as logical entities.

Quoted 1 line

This comment is valid for multiple code below.

Sure, will send out updates.

#13 lore raw

Re: [Patch v8 01/18] net/mana: add basic driver with build environment and doc

In reply to [email protected]
Quoted 42 lines · On 9/8/2022 10:56 PM, [email protected] wrote:

From: Long Li<[email protected]>

MANA is a PCI device. It uses IB verbs to access hardware through the kernel RDMA layer. This patch introduces build environment and basic device probe functions.

---
Change log:
v2:
Fix typos.
Make the driver build only on x86-64 and Linux.
Remove unused header files.
Change port definition to uint16_t or uint8_t (for IB).
Use getline() in place of fgets() to read and truncate a line. v3:
Add meson build check for required functions from RDMA direct verb header file v4:
Remove extra "\n" in logging code.
Use "r" in place of "rb" in fopen() to read text files.
v7:
Remove RTE_ETH_TX_OFFLOAD_TCP_TSO from offload cap.
v8:
Add clarification on driver args usage to nics guide.
Fix coding sytle on function definitions.
Use different variable names in MANA_MKSTR.
Use MANA_ prefix for all macros.
Use RTE_PMD_REGISTER_PCI in place of rte_pci_register.
Add .vendor_id = 0 to the end of PCI table.
Remove RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS from dev_flags.

  MAINTAINERS                       |   6 +
  doc/guides/nics/features/mana.ini |  10 +
  doc/guides/nics/index.rst         |   1 +
  doc/guides/nics/mana.rst          |  69 +++
  drivers/net/mana/mana.c           | 728 ++++++++++++++++++++++++++++++
  drivers/net/mana/mana.h           | 207 +++++++++
  drivers/net/mana/meson.build      |  44 ++
  drivers/net/mana/mp.c             | 241 ++++++++++
  drivers/net/mana/version.map      |   3 +
  drivers/net/meson.build           |   1 +
  10 files changed, 1310 insertions(+)
Quoted 7 lines

create mode 100644 doc/guides/nics/features/mana.ini create mode 100644 doc/guides/nics/mana.rst create mode 100644 drivers/net/mana/mana.c create mode 100644 drivers/net/mana/mana.h create mode 100644 drivers/net/mana/meson.build create mode 100644 drivers/net/mana/mp.c create mode 100644 drivers/net/mana/version.map

Can you please run './devtools/check-meson.py', it complains about 'drivers/net/mana/meson.build'?

#14 lore raw

RE: [Patch v8 01/18] net/mana: add basic driver with build environment and doc

Quoted 56 lines

Subject: Re: [Patch v8 01/18] net/mana: add basic driver with build environment and doc

Quoted 32 lines · On 9/8/2022 10:56 PM, [email protected] wrote:

From: Long Li<[email protected]>

MANA is a PCI device. It uses IB verbs to access hardware through the kernel RDMA layer. This patch introduces build environment and basic device probe functions.

---
Change log:
v2:
Fix typos.
Make the driver build only on x86-64 and Linux.
Remove unused header files.
Change port definition to uint16_t or uint8_t (for IB). Use getline() in place of fgets() to read and truncate a line. v3:
Add meson build check for required functions from RDMA direct verb header file
v4:
Remove extra "\n" in logging code.
Use "r" in place of "rb" in fopen() to read text files. v7:
Remove RTE_ETH_TX_OFFLOAD_TCP_TSO from offload cap.
v8:
Add clarification on driver args usage to nics guide. Fix coding sytle on function definitions.
Use different variable names in MANA_MKSTR.
Use MANA_ prefix for all macros.
Use RTE_PMD_REGISTER_PCI in place of rte_pci_register. Add .vendor_id = 0 to the end of PCI table.
Remove RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS from dev_flags.

Quoted 5 lines
  MAINTAINERS                       |   6 +
  doc/guides/nics/features/mana.ini |  10 +
  doc/guides/nics/index.rst         |   1 +
  doc/guides/nics/mana.rst          |  69 +++
  drivers/net/mana/mana.c           | 728

++++++++++++++++++++++++++++++

Quoted 6 lines
  drivers/net/mana/mana.h           | 207 +++++++++
  drivers/net/mana/meson.build      |  44 ++
  drivers/net/mana/mp.c             | 241 ++++++++++
  drivers/net/mana/version.map      |   3 +
  drivers/net/meson.build           |   1 +
  10 files changed, 1310 insertions(+)
Quoted 7 lines

create mode 100644 doc/guides/nics/features/mana.ini create mode 100644 doc/guides/nics/mana.rst create mode 100644 drivers/net/mana/mana.c create mode 100644 drivers/net/mana/mana.h create mode 100644 drivers/net/mana/meson.build create mode 100644 drivers/net/mana/mp.c create mode 100644 drivers/net/mana/version.map

Quoted 2 lines

Can you please run './devtools/check-meson.py', it complains about 'drivers/net/mana/meson.build'?

Will fix this.

Thanks,
Long

#15 lore raw

v9 cover Introduce Microsoft Azure Network Adatper (MANA) PMD

In reply to [email protected]

From: Long Li <[email protected]>

MANA is a network interface card to be used in the Azure cloud environment. MANA provides safe access to user memory through memory registration. It has IOMMU built into the hardware.

MANA uses IB verbs and RDMA layer to configure hardware resources. It requires the corresponding RDMA kernel-mode and user-mode drivers.

The MANA RDMA kernel-mode driver is being reviewed at:
https://patchwork.kernel.org/project/netdevbpf/list/?series=678843&state=*

The MANA RDMA user-mode driver is being reviewed at:
https://github.com/linux-rdma/rdma-core/pull/1177

Long Li (18):
net/mana: add basic driver with build environment and doc net/mana: device configuration and stop net/mana: report supported ptypes
net/mana: support link update
net/mana: support device removal interrupts net/mana: report device info
net/mana: configure RSS
net/mana: configure Rx queues
net/mana: configure Tx queues
net/mana: implement memory registration net/mana: implement the hardware layer operations net/mana: start/stop Tx queues
net/mana: start/stop Rx queues
net/mana: receive packets
net/mana: send packets
net/mana: start/stop device
net/mana: report queue stats
net/mana: support Rx interrupts

 MAINTAINERS                       |    6 +
 doc/guides/nics/features/mana.ini |   20 +
 doc/guides/nics/index.rst         |    1 +
 doc/guides/nics/mana.rst          |   69 ++
 drivers/net/mana/gdma.c           |  301 ++++++
 drivers/net/mana/mana.c           | 1499 +++++++++++++++++++++++++++++
 drivers/net/mana/mana.h           |  547 +++++++++++
 drivers/net/mana/meson.build      |   48 +
 drivers/net/mana/mp.c             |  336 +++++++
 drivers/net/mana/mr.c             |  348 +++++++
 drivers/net/mana/rx.c             |  531 ++++++++++
 drivers/net/mana/tx.c             |  415 ++++++++
 drivers/net/mana/version.map      |    3 +
 drivers/net/meson.build           |    1 +
 14 files changed, 4125 insertions(+)
 create mode 100644 doc/guides/nics/features/mana.ini
 create mode 100644 doc/guides/nics/mana.rst
 create mode 100644 drivers/net/mana/gdma.c
 create mode 100644 drivers/net/mana/mana.c
 create mode 100644 drivers/net/mana/mana.h
 create mode 100644 drivers/net/mana/meson.build
 create mode 100644 drivers/net/mana/mp.c
 create mode 100644 drivers/net/mana/mr.c
 create mode 100644 drivers/net/mana/rx.c
 create mode 100644 drivers/net/mana/tx.c
 create mode 100644 drivers/net/mana/version.map
Signature · 1 line
2.17.1
#16 lore raw

PATCH v9 1/18 net/mana: add basic driver with build environment and doc

From: Long Li <[email protected]>

MANA is a PCI device. It uses IB verbs to access hardware through the kernel RDMA layer. This patch introduces build environment and basic device probe functions.

---
Change log:
v2:
Fix typos.
Make the driver build only on x86-64 and Linux.
Remove unused header files.
Change port definition to uint16_t or uint8_t (for IB).
Use getline() in place of fgets() to read and truncate a line. v3:
Add meson build check for required functions from RDMA direct verb header file v4:
Remove extra "\n" in logging code.
Use "r" in place of "rb" in fopen() to read text files.
v7:
Remove RTE_ETH_TX_OFFLOAD_TCP_TSO from offload cap.
v8:
Add clarification on driver args usage to nics guide.
Fix coding sytle on function definitions.
Use different variable names in MANA_MKSTR.
Use MANA_ prefix for all macros.
Use RTE_PMD_REGISTER_PCI in place of rte_pci_register.
Add .vendor_id = 0 to the end of PCI table.
Remove RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS from dev_flags.
v9:
Move unused data fields from the header file to later patches that use them. Add minimum required versions in doc/guides/nics/mana.rst.
Remove .name = "net_mana" from rte_pci_driver.

 MAINTAINERS                       |   6 +
 doc/guides/nics/features/mana.ini |  10 +
 doc/guides/nics/index.rst         |   1 +
 doc/guides/nics/mana.rst          |  69 +++
 drivers/net/mana/mana.c           | 725 ++++++++++++++++++++++++++++++
 drivers/net/mana/mana.h           | 102 +++++
 drivers/net/mana/meson.build      |  44 ++
 drivers/net/mana/mp.c             | 241 ++++++++++
 drivers/net/mana/version.map      |   3 +
 drivers/net/meson.build           |   1 +
 10 files changed, 1202 insertions(+)
 create mode 100644 doc/guides/nics/features/mana.ini
 create mode 100644 doc/guides/nics/mana.rst
 create mode 100644 drivers/net/mana/mana.c
 create mode 100644 drivers/net/mana/mana.h
 create mode 100644 drivers/net/mana/meson.build
 create mode 100644 drivers/net/mana/mp.c
 create mode 100644 drivers/net/mana/version.map
MAINTAINERS +6 -0
index 18d9edaf88..b8bda48a33 100644
@@ -837,6 +837,12 @@ F: buildtools/options-ibverbs-static.sh
 F: doc/guides/nics/mlx5.rst
 F: doc/guides/nics/features/mlx5.ini
 
+Microsoft mana
+M: Long Li <[email protected]>
+F: drivers/net/mana
+F: doc/guides/nics/mana.rst
+F: doc/guides/nics/features/mana.ini
+
 Microsoft vdev_netvsc - EXPERIMENTAL
 M: Matan Azrad <[email protected]>
 F: drivers/net/vdev_netvsc/
doc/guides/nics/features/mana.ini new file +10 -0
new file mode 100644
index 0000000000..b92a27374c
@@ -0,0 +1,10 @@
+;
+; Supported features of the 'mana' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+Multiprocess aware   = Y
+Usage doc            = Y
+x86-64               = Y
doc/guides/nics/index.rst +1 -0
index 1c94caccea..2725d1d9f0 100644
@@ -41,6 +41,7 @@ Network Interface Controller Drivers
     intel_vf
     kni
     liquidio
+    mana
     memif
     mlx4
     mlx5
doc/guides/nics/mana.rst new file +69 -0

69 lines not on this page · raw message

drivers/net/mana/mana.c new file +725 -0

725 lines not on this page · raw message

drivers/net/mana/mana.h new file +102 -0

102 lines not on this page · raw message

drivers/net/mana/meson.build new file +44 -0

44 lines not on this page · raw message

drivers/net/mana/mp.c new file +241 -0

241 lines not on this page · raw message

drivers/net/mana/version.map new file +3 -0
new file mode 100644
index 0000000000..78c3585d7c
@@ -0,0 +1,3 @@
+DPDK_23 {
+	local: *;
+};
drivers/net/meson.build +1 -0
index 2355d1cde8..0b111a6ebb 100644
@@ -34,6 +34,7 @@ drivers = [
         'ixgbe',
         'kni',
         'liquidio',
+        'mana',
         'memif',
         'mlx4',
         'mlx5',
Signature · 1 line
2.17.1
#17 lore raw

Re: [Patch v9 01/18] net/mana: add basic driver with build environment and doc

Quoted 8 lines · On 9/24/2022 3:45 AM, [email protected] wrote:

From: Long Li <[email protected]>

MANA is a PCI device. It uses IB verbs to access hardware through the kernel RDMA layer. This patch introduces build environment and basic device probe functions.

<...>

Quoted 15 lines

+++ b/doc/guides/nics/mana.rst

doc/guides/nics/mana.rst new file +13 -0
@@ -0,0 +1,69 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright 2022 Microsoft Corporation
+
+MANA poll mode driver library
+=============================
+
+The MANA poll mode driver library (**librte_net_mana**) implements support
+for Microsoft Azure Network Adapter VF in SR-IOV context.
+
+Features
+--------
+
+Features of the MANA Ethdev PMD are:

doc/guides/nics/mana.rst line 23

Quoted 10 lines
doc/guides/nics/mana.rst new file +10 -0
+
+Prerequisites
+-------------
+
+This driver relies on external libraries and kernel drivers for resources
+allocations and initialization. The following dependencies are not part of
+DPDK and must be installed separately:
+
+- **libibverbs** (provided by rdma-core package)
+

Does it make sense to provide rdma-core git repo link?

<...>

drivers/net/mana/mana.c line 70

Quoted 3 lines
drivers/net/mana/mana.c new file +3 -0
+
+static const char * const mana_init_args[] = {
+       "mac",

It is better to define a macro for the devarg string to be able to reuse it in 'RTE_PMD_REGISTER_PARAM_STRING' (please see below).

#define ETH_MANA_MAC_ARG "mac"
static const char * const mana_init_args[] = {
ETH_MANA_MAC_ARG,
NULL,
};

<...>

Quoted 100 lines
drivers/net/mana/mana.c new file +100 -0
+
+/*
+ * Goes through the IB device list to look for the IB port matching the
+ * mac_addr. If found, create a rte_eth_dev for it.
+ */
+static int
+mana_pci_probe_mac(struct rte_pci_device *pci_dev,
+                  struct rte_ether_addr *mac_addr)
+{
+       struct ibv_device **ibv_list;
+       int ibv_idx;
+       struct ibv_context *ctx;
+       struct ibv_device_attr_ex dev_attr;
+       int num_devices;
+       int ret = 0;
+       uint8_t port;
+       struct mana_priv *priv = NULL;
+       struct rte_eth_dev *eth_dev = NULL;
+       bool found_port;
+
+       ibv_list = ibv_get_device_list(&num_devices);
+       for (ibv_idx = 0; ibv_idx < num_devices; ibv_idx++) {
+               struct ibv_device *ibdev = ibv_list[ibv_idx];
+               struct rte_pci_addr pci_addr;
+
+               DRV_LOG(INFO, "Probe device name %s dev_name %s ibdev_path %s",
+                       ibdev->name, ibdev->dev_name, ibdev->ibdev_path);
+
+               if (mana_ibv_device_to_pci_addr(ibdev, &pci_addr))
+                       continue;
+
+               /* Ignore if this IB device is not this PCI device */
+               if (pci_dev->addr.domain != pci_addr.domain ||
+                   pci_dev->addr.bus != pci_addr.bus ||
+                   pci_dev->addr.devid != pci_addr.devid ||
+                   pci_dev->addr.function != pci_addr.function)
+                       continue;
+
+               ctx = ibv_open_device(ibdev);
+               if (!ctx) {
+                       DRV_LOG(ERR, "Failed to open IB device %s",
+                               ibdev->name);
+                       continue;
+               }
+
+               ret = ibv_query_device_ex(ctx, NULL, &dev_attr);
+               DRV_LOG(INFO, "dev_attr.orig_attr.phys_port_cnt %u",
+                       dev_attr.orig_attr.phys_port_cnt);
+               found_port = false;
+
+               for (port = 1; port <= dev_attr.orig_attr.phys_port_cnt;
+                    port++) {
+                       struct ibv_parent_domain_init_attr attr = {0};
+                       struct rte_ether_addr addr;
+                       char address[64];
+                       char name[RTE_ETH_NAME_MAX_LEN];
+
+                       ret = get_port_mac(ibdev, port, &addr);
+                       if (ret)
+                               continue;
+
+                       if (mac_addr && !rte_is_same_ether_addr(&addr, mac_addr))
+                               continue;
+
+                       rte_ether_format_addr(address, sizeof(address), &addr);
+                       DRV_LOG(INFO, "device located port %u address %s",
+                               port, address);
+                       found_port = true;
+
+                       priv = rte_zmalloc_socket(NULL, sizeof(*priv),
+                                                 RTE_CACHE_LINE_SIZE,
+                                                 SOCKET_ID_ANY);
+                       if (!priv) {
+                               ret = -ENOMEM;
+                               goto failed;
+                       }
+
+                       snprintf(name, sizeof(name), "%s_port%d",
+                                pci_dev->device.name, port);
+
+                       if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+                               int fd;
+
+                               eth_dev = rte_eth_dev_attach_secondary(name);
+                               if (!eth_dev) {
+                                       DRV_LOG(ERR, "Can't attach to dev %s",
+                                               name);
+                                       ret = -ENOMEM;
+                                       goto failed;
+                               }
+
+                               eth_dev->device = &pci_dev->device;
+                               eth_dev->dev_ops = &mana_dev_secondary_ops;
+                               ret = mana_proc_priv_init(eth_dev);
+                               if (ret)
+                                       goto failed;
+                               priv->process_priv = eth_dev->process_private;
+
+                               /* Get the IB FD from the primary process */
+                               fd = mana_mp_req_verbs_cmd_fd(eth_dev);

drivers/net/mana/mana.c line 474

Quoted 10 lines
drivers/net/mana/mana.c new file +10 -0
+                               if (fd < 0) {
+                                       DRV_LOG(ERR, "Failed to get FD %d", fd);
+                                       ret = -ENODEV;
+                                       goto failed;
+                               }
+
+                               ret = mana_map_doorbell_secondary(eth_dev, fd);
+                               if (ret) {
+                                       DRV_LOG(ERR, "Failed secondary map %d",
+                                               fd);

The indentation level (and lenght) of this functions hints that some part of it can be seprated as function, like probe one 'ibv_device' can be on its own function.

Can you refactor the function, to increase readability? It is control path, so there is no restriction to have function calls.

Quoted 78 lines
drivers/net/mana/mana.c new file +78 -0
+                                       goto failed;
+                               }
+
+                               /* fd is no not used after mapping doorbell */
+                               close(fd);
+
+                               rte_spinlock_lock(&mana_shared_data->lock);
+                               mana_shared_data->secondary_cnt++;
+                               mana_local_data.secondary_cnt++;
+                               rte_spinlock_unlock(&mana_shared_data->lock);
+
+                               rte_eth_copy_pci_info(eth_dev, pci_dev);
+                               rte_eth_dev_probing_finish(eth_dev);
+
+                               /* Impossible to have more than one port
+                                * matching a MAC address
+                                */
+                               continue;
+                       }
+
+                       eth_dev = rte_eth_dev_allocate(name);
+                       if (!eth_dev) {
+                               ret = -ENOMEM;
+                               goto failed;
+                       }
+
+                       eth_dev->data->mac_addrs =
+                               rte_calloc("mana_mac", 1,
+                                          sizeof(struct rte_ether_addr), 0);
+                       if (!eth_dev->data->mac_addrs) {
+                               ret = -ENOMEM;
+                               goto failed;
+                       }
+
+                       rte_ether_addr_copy(&addr, eth_dev->data->mac_addrs);
+
+                       priv->ib_pd = ibv_alloc_pd(ctx);
+                       if (!priv->ib_pd) {
+                               DRV_LOG(ERR, "ibv_alloc_pd failed port %d", port);
+                               ret = -ENOMEM;
+                               goto failed;
+                       }
+
+                       /* Create a parent domain with the port number */
+                       attr.pd = priv->ib_pd;
+                       attr.comp_mask = IBV_PARENT_DOMAIN_INIT_ATTR_PD_CONTEXT;
+                       attr.pd_context = (void *)(uint64_t)port;
+                       priv->ib_parent_pd = ibv_alloc_parent_domain(ctx, &attr);
+                       if (!priv->ib_parent_pd) {
+                               DRV_LOG(ERR,
+                                       "ibv_alloc_parent_domain failed port %d",
+                                       port);
+                               ret = -ENOMEM;
+                               goto failed;
+                       }
+
+                       priv->ib_ctx = ctx;
+                       priv->port_id = eth_dev->data->port_id;
+                       priv->dev_port = port;
+                       eth_dev->data->dev_private = priv;
+                       priv->dev_data = eth_dev->data;
+
+                       priv->max_rx_queues = dev_attr.orig_attr.max_qp;
+                       priv->max_tx_queues = dev_attr.orig_attr.max_qp;
+
+                       priv->max_rx_desc =
+                               RTE_MIN(dev_attr.orig_attr.max_qp_wr,
+                                       dev_attr.orig_attr.max_cqe);
+                       priv->max_tx_desc =
+                               RTE_MIN(dev_attr.orig_attr.max_qp_wr,
+                                       dev_attr.orig_attr.max_cqe);
+
+                       priv->max_send_sge = dev_attr.orig_attr.max_sge;
+                       priv->max_recv_sge = dev_attr.orig_attr.max_sge;
+
+                       priv->max_mr = dev_attr.orig_attr.max_mr;
+                       priv->max_mr_size = dev_attr.orig_attr.max_mr_size;
+

drivers/net/mana/mana.c line 562

Quoted 10 lines
drivers/net/mana/mana.c new file +10 -0
+                       DRV_LOG(INFO, "dev %s max queues %d desc %d sge %d",
+                               name, priv->max_rx_queues, priv->max_rx_desc,
+                               priv->max_send_sge);
+
+                       rte_spinlock_lock(&mana_shared_data->lock);
+                       mana_shared_data->primary_cnt++;
+                       rte_spinlock_unlock(&mana_shared_data->lock);
+
+                       eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_RMV;
+

This assignment already done by 'rte_eth_copy_pci_info()' when 'RTE_PCI_DRV_INTR_RMV' driver flag set which this PMD sets, so assignment is redundant.

<...>

drivers/net/mana/mana.c line 725

Quoted 6 lines
drivers/net/mana/mana.c new file +6 -0
+
+RTE_PMD_REGISTER_PCI(net_mana, mana_pci_driver);
+RTE_PMD_REGISTER_PCI_TABLE(net_mana, mana_pci_id_map);
+RTE_PMD_REGISTER_KMOD_DEP(net_mana, "* ib_uverbs & mana_ib");
+RTE_LOG_REGISTER_SUFFIX(mana_logtype_init, init, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(mana_logtype_driver, driver, NOTICE);

Can you please add 'RTE_PMD_REGISTER_PARAM_STRING' macro for 'mac' devarg?

Quoted 10 lines
drivers/net/mana/mana.h new file +4 -0
new file mode 100644
index 0000000000..a2021ceb4a
@@ -0,0 +1,102 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2022 Microsoft Corporation
+ */
+

drivers/net/mana/mana.h line 14

Quoted 10 lines
drivers/net/mana/mana.h new file +10 -0
+#ifndef __MANA_H__
+#define __MANA_H__
+
+enum {
+       PCI_VENDOR_ID_MICROSOFT = 0x1414,
+};
+
+enum {
+       PCI_DEVICE_ID_MICROSOFT_MANA = 0x00ba,
+};

There is a common guidance to prefer enums against define BUT,

I tend to use enums for related cases, or when underneath numerical value doesn't matter.

For PCI IDs I would use #define, although both works same, what do you think to update them to define?

#18 lore raw

PATCH v9 2/18 net/mana: device configuration and stop

In reply to [email protected]

From: Long Li <[email protected]>

MANA defines its memory allocation functions to override IB layer default functions to allocate device queues. This patch adds the code for device configuration and stop.

---
v2:
Removed validation for offload settings in mana_dev_configure(). v8:
Fix coding style to function definitions.

 drivers/net/mana/mana.c | 81 ++++++++++++++++++++++++++++++++++++++++-
 drivers/net/mana/mana.h |  4 ++
 2 files changed, 83 insertions(+), 2 deletions(-)
drivers/net/mana/mana.c +79 -2
index 1c317418b6..64069e2b9f 100644
@@ -42,7 +42,85 @@ static rte_spinlock_t mana_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
 int mana_logtype_driver;
 int mana_logtype_init;
 
+/*
+ * Callback from rdma-core to allocate a buffer for a queue.
+ */
+void *
+mana_alloc_verbs_buf(size_t size, void *data)
+{
+	void *ret;
+	size_t alignment = rte_mem_page_size();
+	int socket = (int)(uintptr_t)data;
+
+	DRV_LOG(DEBUG, "size=%zu socket=%d", size, socket);
+
+	if (alignment == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
+
+	ret = rte_zmalloc_socket("mana_verb_buf", size, alignment, socket);
+	if (!ret && size)
+		rte_errno = ENOMEM;
+	return ret;
+}
+
+void
+mana_free_verbs_buf(void *ptr, void *data __rte_unused)
+{
+	rte_free(ptr);
+}
+
+static int
+mana_dev_configure(struct rte_eth_dev *dev)
+{
+	struct mana_priv *priv = dev->data->dev_private;
+	struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
+
+	if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
+		dev_conf->rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH;
+
+	if (dev->data->nb_rx_queues != dev->data->nb_tx_queues) {
+		DRV_LOG(ERR, "Only support equal number of rx/tx queues");
+		return -EINVAL;
+	}
+
+	if (!rte_is_power_of_2(dev->data->nb_rx_queues)) {
+		DRV_LOG(ERR, "number of TX/RX queues must be power of 2");
+		return -EINVAL;
+	}
+
+	priv->num_queues = dev->data->nb_rx_queues;
+
+	manadv_set_context_attr(priv->ib_ctx, MANADV_CTX_ATTR_BUF_ALLOCATORS,
+				(void *)((uintptr_t)&(struct manadv_ctx_allocators){
+					.alloc = &mana_alloc_verbs_buf,
+					.free = &mana_free_verbs_buf,
+					.data = 0,
+				}));
+
+	return 0;
+}
+
+static int
+mana_dev_close(struct rte_eth_dev *dev)
+{
+	struct mana_priv *priv = dev->data->dev_private;
+	int ret;
+
+	ret = ibv_close_device(priv->ib_ctx);
+	if (ret) {
+		ret = errno;
+		return ret;
+	}
+
+	return 0;
+}
+
 static const struct eth_dev_ops mana_dev_ops = {
+	.dev_configure		= mana_dev_configure,
+	.dev_close		= mana_dev_close,
 };
 
 static const struct eth_dev_ops mana_dev_secondary_ops = {
@@ -649,8 +727,7 @@ mana_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 static int
 mana_dev_uninit(struct rte_eth_dev *dev)
 {
-	RTE_SET_USED(dev);
-	return 0;
+	return mana_dev_close(dev);
 }
 
 /*
drivers/net/mana/mana.h +4 -0
index a2021ceb4a..0b4a828b0a 100644
@@ -28,6 +28,7 @@ struct mana_process_priv {
 struct mana_priv {
 	struct rte_eth_dev_data *dev_data;
 	struct mana_process_priv *process_priv;
+	int num_queues;
 
 	/* DPDK port */
 	uint16_t port_id;
@@ -99,4 +100,7 @@ int mana_mp_req_verbs_cmd_fd(struct rte_eth_dev *dev);
 
 void mana_mp_req_on_rxtx(struct rte_eth_dev *dev, enum mana_mp_req_type type);
 
+void *mana_alloc_verbs_buf(size_t size, void *data);
+void mana_free_verbs_buf(void *ptr, void *data __rte_unused);
+
 #endif
Signature · 1 line
2.17.1
#19 lore raw

PATCH v9 3/18 net/mana: report supported ptypes

In reply to [email protected]

From: Long Li <[email protected]>

Report supported protocol types.

---
Change log.
v7: change link_speed to RTE_ETH_SPEED_NUM_100G

 drivers/net/mana/mana.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/net/mana/mana.c +17 -0
index 64069e2b9f..5fc656110f 100644
@@ -118,9 +118,26 @@ mana_dev_close(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static const uint32_t *
+mana_supported_ptypes(struct rte_eth_dev *dev __rte_unused)
+{
+	static const uint32_t ptypes[] = {
+		RTE_PTYPE_L2_ETHER,
+		RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
+		RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
+		RTE_PTYPE_L4_FRAG,
+		RTE_PTYPE_L4_TCP,
+		RTE_PTYPE_L4_UDP,
+		RTE_PTYPE_UNKNOWN
+	};
+
+	return ptypes;
+}
+
 static const struct eth_dev_ops mana_dev_ops = {
 	.dev_configure		= mana_dev_configure,
 	.dev_close		= mana_dev_close,
+	.dev_supported_ptypes_get = mana_supported_ptypes,
 };
 
 static const struct eth_dev_ops mana_dev_secondary_ops = {
Signature · 1 line
2.17.1
#20 lore raw

PATCH v9 4/18 net/mana: support link update

In reply to [email protected]

From: Long Li <[email protected]>

The carrier state is managed by the Azure host. MANA runs as a VF and always reports "up".

---
 doc/guides/nics/features/mana.ini |  1 +
 drivers/net/mana/mana.c           | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
index b92a27374c..62554b0a0a 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Link status          = P
 Linux                = Y
 Multiprocess aware   = Y
 Usage doc            = Y
drivers/net/mana/mana.c +18 -0
index 5fc656110f..90e713318a 100644
@@ -134,10 +134,28 @@ mana_supported_ptypes(struct rte_eth_dev *dev __rte_unused)
 	return ptypes;
 }
 
+static int
+mana_dev_link_update(struct rte_eth_dev *dev,
+		     int wait_to_complete __rte_unused)
+{
+	struct rte_eth_link link;
+
+	/* MANA has no concept of carrier state, always reporting UP */
+	link = (struct rte_eth_link) {
+		.link_duplex = RTE_ETH_LINK_FULL_DUPLEX,
+		.link_autoneg = RTE_ETH_LINK_SPEED_FIXED,
+		.link_speed = RTE_ETH_SPEED_NUM_100G,
+		.link_status = RTE_ETH_LINK_UP,
+	};
+
+	return rte_eth_linkstatus_set(dev, &link);
+}
+
 static const struct eth_dev_ops mana_dev_ops = {
 	.dev_configure		= mana_dev_configure,
 	.dev_close		= mana_dev_close,
 	.dev_supported_ptypes_get = mana_supported_ptypes,
+	.link_update		= mana_dev_link_update,
 };
 
 static const struct eth_dev_ops mana_dev_secondary_ops = {
Signature · 1 line
2.17.1
#21 lore raw

PATCH v9 5/18 net/mana: support device removal interrupts

In reply to [email protected]

From: Long Li <[email protected]>

MANA supports PCI hot plug events. Add this interrupt to DPDK core so its parent PMD can detect device removal during Azure servicing or live migration.

---
v8:
fix coding style of function definitions.
v9:
remove unused data fields.

 doc/guides/nics/features/mana.ini |   1 +
 drivers/net/mana/mana.c           | 103 ++++++++++++++++++++++++++++++
 drivers/net/mana/mana.h           |   1 +
 3 files changed, 105 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
index 62554b0a0a..8043e11f99 100644
@@ -7,5 +7,6 @@
 Link status          = P
 Linux                = Y
 Multiprocess aware   = Y
+Removal event        = Y
 Usage doc            = Y
 x86-64               = Y
drivers/net/mana/mana.c +103 -0

127 lines not on this page · raw message

drivers/net/mana/mana.h +1 -0
index 0b4a828b0a..d9eb19559d 100644
@@ -40,6 +40,7 @@ struct mana_priv {
 	struct ibv_pd *ib_pd;
 	struct ibv_pd *ib_parent_pd;
 	void *db_page;
+	struct rte_intr_handle *intr_handle;
 	int max_rx_queues;
 	int max_tx_queues;
 	int max_rx_desc;
Signature · 1 line
2.17.1
#22 lore raw

PATCH v9 6/18 net/mana: report device info

In reply to [email protected]

From: Long Li <[email protected]>

Add the function to get device info.

---
v8:
use new macro definition start with "MANA_"
fix coding style to function definitions

v9:
move data definitions from earlier patch.

 doc/guides/nics/features/mana.ini |  1 +
 drivers/net/mana/mana.c           | 83 +++++++++++++++++++++++++++++++
 drivers/net/mana/mana.h           | 28 +++++++++++
 3 files changed, 112 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
index 8043e11f99..566b3e8770 100644
@@ -8,5 +8,6 @@ Link status          = P
 Linux                = Y
 Multiprocess aware   = Y
 Removal event        = Y
+Speed capabilities   = P
 Usage doc            = Y
 x86-64               = Y
drivers/net/mana/mana.c +83 -0

100 lines not on this page · raw message

drivers/net/mana/mana.h +28 -0
index d9eb19559d..2d280785ec 100644
@@ -21,6 +21,34 @@ struct mana_shared_data {
 	unsigned int secondary_cnt;
 };
 
+#define MIN_RX_BUF_SIZE	1024
+#define MAX_FRAME_SIZE	RTE_ETHER_MAX_LEN
+#define MANA_MAX_MAC_ADDR 1
+
+#define MANA_DEV_RX_OFFLOAD_SUPPORT ( \
+		DEV_RX_OFFLOAD_CHECKSUM | \
+		DEV_RX_OFFLOAD_RSS_HASH)
+
+#define MANA_DEV_TX_OFFLOAD_SUPPORT ( \
+		RTE_ETH_TX_OFFLOAD_MULTI_SEGS | \
+		RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | \
+		RTE_ETH_TX_OFFLOAD_TCP_CKSUM | \
+		RTE_ETH_TX_OFFLOAD_UDP_CKSUM)
+
+#define INDIRECTION_TABLE_NUM_ELEMENTS 64
+#define TOEPLITZ_HASH_KEY_SIZE_IN_BYTES 40
+#define MANA_ETH_RSS_SUPPORT ( \
+	ETH_RSS_IPV4 |	     \
+	ETH_RSS_NONFRAG_IPV4_TCP | \
+	ETH_RSS_NONFRAG_IPV4_UDP | \
+	ETH_RSS_IPV6 |	     \
+	ETH_RSS_NONFRAG_IPV6_TCP | \
+	ETH_RSS_NONFRAG_IPV6_UDP)
+
+#define MIN_BUFFERS_PER_QUEUE		64
+#define MAX_RECEIVE_BUFFERS_PER_QUEUE	256
+#define MAX_SEND_BUFFERS_PER_QUEUE	256
+
 struct mana_process_priv {
 	void *db_page;
 };
Signature · 1 line
2.17.1
#23 lore raw

PATCH v9 7/18 net/mana: configure RSS

In reply to [email protected]

From: Long Li <[email protected]>

Currently this PMD supports RSS configuration when the device is stopped. Configuring RSS in running state will be supported in the future.

---
change log:
v8:
fix coding sytle to function definitions

 doc/guides/nics/features/mana.ini |  1 +
 drivers/net/mana/mana.c           | 65 ++++++++++++++++++++++++++++++-
 drivers/net/mana/mana.h           |  1 +
 3 files changed, 66 insertions(+), 1 deletion(-)
doc/guides/nics/features/mana.ini +1 -0
index 566b3e8770..a59c21cc10 100644
@@ -8,6 +8,7 @@ Link status          = P
 Linux                = Y
 Multiprocess aware   = Y
 Removal event        = Y
+RSS hash             = Y
 Speed capabilities   = P
 Usage doc            = Y
 x86-64               = Y
drivers/net/mana/mana.c +64 -1

79 lines not on this page · raw message

drivers/net/mana/mana.h +1 -0
index 2d280785ec..8d8be3d4eb 100644
@@ -68,6 +68,7 @@ struct mana_priv {
 	struct ibv_pd *ib_pd;
 	struct ibv_pd *ib_parent_pd;
 	void *db_page;
+	struct rte_eth_rss_conf rss_conf;
 	struct rte_intr_handle *intr_handle;
 	int max_rx_queues;
 	int max_tx_queues;
Signature · 1 line
2.17.1
#24 lore raw

Re: [Patch v9 07/18] net/mana: configure RSS

Quoted 7 lines · On 9/24/2022 3:45 AM, [email protected] wrote:

From: Long Li <[email protected]>

Currently this PMD supports RSS configuration when the device is stopped. Configuring RSS in running state will be supported in the future.

<...>

drivers/net/mana/mana.c mana_supported_ptypes(struct rte_eth_dev *dev __rte_unused) · line 287

Quoted 5 lines
drivers/net/mana/mana.c +2 -1
+
  static int
  mana_dev_link_update(struct rte_eth_dev *dev,
-                    int wait_to_complete __rte_unused)
+                               int wait_to_complete __rte_unused)

Instead of changing here, can you please add this right at first place?

#25 lore raw

PATCH v9 8/18 net/mana: configure Rx queues

In reply to [email protected]

From: Long Li <[email protected]>

Rx hardware queue is allocated when starting the queue. This function is for queue configuration pre starting.

---
Change log:
v8:
fix coding style to function definitions
v9:
move data defintions from earlier patch.

 drivers/net/mana/mana.c | 73 ++++++++++++++++++++++++++++++++++++++++-
 drivers/net/mana/mana.h | 21 ++++++++++++
 2 files changed, 93 insertions(+), 1 deletion(-)
drivers/net/mana/mana.c +72 -1
index bbaaa8c233..1c5416fac5 100644
@@ -205,6 +205,17 @@ mana_dev_info_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static void
+mana_dev_rx_queue_info(struct rte_eth_dev *dev, uint16_t queue_id,
+		       struct rte_eth_rxq_info *qinfo)
+{
+	struct mana_rxq *rxq = dev->data->rx_queues[queue_id];
+
+	qinfo->mp = rxq->mp;
+	qinfo->nb_desc = rxq->num_desc;
+	qinfo->conf.offloads = dev->data->dev_conf.rxmode.offloads;
+}
+
 static const uint32_t *
 mana_supported_ptypes(struct rte_eth_dev *dev __rte_unused)
 {
@@ -282,9 +293,66 @@ mana_rss_hash_conf_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+mana_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
+			uint16_t nb_desc, unsigned int socket_id,
+			const struct rte_eth_rxconf *rx_conf __rte_unused,
+			struct rte_mempool *mp)
+{
+	struct mana_priv *priv = dev->data->dev_private;
+	struct mana_rxq *rxq;
+	int ret;
+
+	rxq = rte_zmalloc_socket("mana_rxq", sizeof(*rxq), 0, socket_id);
+	if (!rxq) {
+		DRV_LOG(ERR, "failed to allocate rxq");
+		return -ENOMEM;
+	}
+
+	DRV_LOG(DEBUG, "idx %u nb_desc %u socket %u",
+		queue_idx, nb_desc, socket_id);
+
+	rxq->socket = socket_id;
+
+	rxq->desc_ring = rte_zmalloc_socket("mana_rx_mbuf_ring",
+					    sizeof(struct mana_rxq_desc) *
+						nb_desc,
+					    RTE_CACHE_LINE_SIZE, socket_id);
+
+	if (!rxq->desc_ring) {
+		DRV_LOG(ERR, "failed to allocate rxq desc_ring");
+		ret = -ENOMEM;
+		goto fail;
+	}
+
+	rxq->desc_ring_head = 0;
+	rxq->desc_ring_tail = 0;
+
+	rxq->priv = priv;
+	rxq->num_desc = nb_desc;
+	rxq->mp = mp;
+	dev->data->rx_queues[queue_idx] = rxq;
+
+	return 0;
+
+fail:
+	rte_free(rxq->desc_ring);
+	rte_free(rxq);
+	return ret;
+}
+
+static void
+mana_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
+{
+	struct mana_rxq *rxq = dev->data->rx_queues[qid];
+
+	rte_free(rxq->desc_ring);
+	rte_free(rxq);
+}
+
 static int
 mana_dev_link_update(struct rte_eth_dev *dev,
-				int wait_to_complete __rte_unused)
+		     int wait_to_complete __rte_unused)
 {
 	struct rte_eth_link link;
 
@@ -303,9 +371,12 @@ static const struct eth_dev_ops mana_dev_ops = {
 	.dev_configure		= mana_dev_configure,
 	.dev_close		= mana_dev_close,
 	.dev_infos_get		= mana_dev_info_get,
+	.rxq_info_get		= mana_dev_rx_queue_info,
 	.dev_supported_ptypes_get = mana_supported_ptypes,
 	.rss_hash_update	= mana_rss_hash_update,
 	.rss_hash_conf_get	= mana_rss_hash_conf_get,
+	.rx_queue_setup		= mana_dev_rx_queue_setup,
+	.rx_queue_release	= mana_dev_rx_queue_release,
 	.link_update		= mana_dev_link_update,
 };
 
drivers/net/mana/mana.h +21 -0
index 8d8be3d4eb..a436d6cfc9 100644
@@ -80,6 +80,27 @@ struct mana_priv {
 	uint64_t max_mr_size;
 };
 
+struct mana_rxq_desc {
+	struct rte_mbuf *pkt;
+	uint32_t wqe_size_in_bu;
+};
+
+struct mana_rxq {
+	struct mana_priv *priv;
+	uint32_t num_desc;
+	struct rte_mempool *mp;
+
+	/* For storing pending requests */
+	struct mana_rxq_desc *desc_ring;
+
+	/* desc_ring_head is where we put pending requests to ring,
+	 * completion pull off desc_ring_tail
+	 */
+	uint32_t desc_ring_head, desc_ring_tail;
+
+	unsigned int socket;
+};
+
 extern int mana_logtype_driver;
 extern int mana_logtype_init;
 
Signature · 1 line
2.17.1
#26 lore raw

PATCH v9 9/18 net/mana: configure Tx queues

In reply to [email protected]

From: Long Li <[email protected]>

Tx hardware queue is allocated when starting the queue, this is for pre configuration.

---
change log:
v8:
fix coding style to function definitions
v9:
move data definitions from earlier patch.

 drivers/net/mana/mana.c | 67 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/mana/mana.h | 20 ++++++++++++
 2 files changed, 87 insertions(+)
drivers/net/mana/mana.c +67 -0
index 1c5416fac5..a8a792d5f8 100644
@@ -205,6 +205,16 @@ mana_dev_info_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static void
+mana_dev_tx_queue_info(struct rte_eth_dev *dev, uint16_t queue_id,
+		       struct rte_eth_txq_info *qinfo)
+{
+	struct mana_txq *txq = dev->data->tx_queues[queue_id];
+
+	qinfo->conf.offloads = dev->data->dev_conf.txmode.offloads;
+	qinfo->nb_desc = txq->num_desc;
+}
+
 static void
 mana_dev_rx_queue_info(struct rte_eth_dev *dev, uint16_t queue_id,
 		       struct rte_eth_rxq_info *qinfo)
@@ -293,6 +303,60 @@ mana_rss_hash_conf_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+mana_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
+			uint16_t nb_desc, unsigned int socket_id,
+			const struct rte_eth_txconf *tx_conf __rte_unused)
+
+{
+	struct mana_priv *priv = dev->data->dev_private;
+	struct mana_txq *txq;
+	int ret;
+
+	txq = rte_zmalloc_socket("mana_txq", sizeof(*txq), 0, socket_id);
+	if (!txq) {
+		DRV_LOG(ERR, "failed to allocate txq");
+		return -ENOMEM;
+	}
+
+	txq->socket = socket_id;
+
+	txq->desc_ring = rte_malloc_socket("mana_tx_desc_ring",
+					   sizeof(struct mana_txq_desc) *
+						nb_desc,
+					   RTE_CACHE_LINE_SIZE, socket_id);
+	if (!txq->desc_ring) {
+		DRV_LOG(ERR, "failed to allocate txq desc_ring");
+		ret = -ENOMEM;
+		goto fail;
+	}
+
+	DRV_LOG(DEBUG, "idx %u nb_desc %u socket %u txq->desc_ring %p",
+		queue_idx, nb_desc, socket_id, txq->desc_ring);
+
+	txq->desc_ring_head = 0;
+	txq->desc_ring_tail = 0;
+	txq->priv = priv;
+	txq->num_desc = nb_desc;
+	dev->data->tx_queues[queue_idx] = txq;
+
+	return 0;
+
+fail:
+	rte_free(txq->desc_ring);
+	rte_free(txq);
+	return ret;
+}
+
+static void
+mana_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
+{
+	struct mana_txq *txq = dev->data->tx_queues[qid];
+
+	rte_free(txq->desc_ring);
+	rte_free(txq);
+}
+
 static int
 mana_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
@@ -371,10 +435,13 @@ static const struct eth_dev_ops mana_dev_ops = {
 	.dev_configure		= mana_dev_configure,
 	.dev_close		= mana_dev_close,
 	.dev_infos_get		= mana_dev_info_get,
+	.txq_info_get		= mana_dev_tx_queue_info,
 	.rxq_info_get		= mana_dev_rx_queue_info,
 	.dev_supported_ptypes_get = mana_supported_ptypes,
 	.rss_hash_update	= mana_rss_hash_update,
 	.rss_hash_conf_get	= mana_rss_hash_conf_get,
+	.tx_queue_setup		= mana_dev_tx_queue_setup,
+	.tx_queue_release	= mana_dev_tx_queue_release,
 	.rx_queue_setup		= mana_dev_rx_queue_setup,
 	.rx_queue_release	= mana_dev_rx_queue_release,
 	.link_update		= mana_dev_link_update,
drivers/net/mana/mana.h +20 -0
index a436d6cfc9..817ac75f69 100644
@@ -80,11 +80,31 @@ struct mana_priv {
 	uint64_t max_mr_size;
 };
 
+struct mana_txq_desc {
+	struct rte_mbuf *pkt;
+	uint32_t wqe_size_in_bu;
+};
+
 struct mana_rxq_desc {
 	struct rte_mbuf *pkt;
 	uint32_t wqe_size_in_bu;
 };
 
+struct mana_txq {
+	struct mana_priv *priv;
+	uint32_t num_desc;
+
+	/* For storing pending requests */
+	struct mana_txq_desc *desc_ring;
+
+	/* desc_ring_head is where we put pending requests to ring,
+	 * completion pull off desc_ring_tail
+	 */
+	uint32_t desc_ring_head, desc_ring_tail;
+
+	unsigned int socket;
+};
+
 struct mana_rxq {
 	struct mana_priv *priv;
 	uint32_t num_desc;
Signature · 1 line
2.17.1
#27 lore raw

PATCH v9 10/18 net/mana: implement memory registration

In reply to [email protected]

From: Long Li <[email protected]>

MANA hardware has iommu built-in, that provides hardware safe access to user memory through memory registration. Since memory registration is an expensive operation, this patch implements a two level memory registration cache mechanisum for each queue and for each port.

---
v2:
Change all header file functions to start with mana_. Use spinlock in place of rwlock to memory cache access. Remove unused header files.
v4:
Remove extra "\n" in logging function.
v8:
Fix Coding style to function definitions.
v9:
Move data definitions from earlier patch.

 drivers/net/mana/mana.c      |  20 ++
 drivers/net/mana/mana.h      |  42 +++++
 drivers/net/mana/meson.build |   1 +
 drivers/net/mana/mp.c        |  92 +++++++++
 drivers/net/mana/mr.c        | 348 +++++++++++++++++++++++++++++++++++
 5 files changed, 503 insertions(+)
 create mode 100644 drivers/net/mana/mr.c
drivers/net/mana/mana.c +20 -0
index a8a792d5f8..a3c949d408 100644
@@ -111,6 +111,8 @@ mana_dev_close(struct rte_eth_dev *dev)
 	struct mana_priv *priv = dev->data->dev_private;
 	int ret;
 
+	mana_remove_all_mr(priv);
+
 	ret = mana_intr_uninstall(priv);
 	if (ret)
 		return ret;
@@ -331,6 +333,13 @@ mana_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 		goto fail;
 	}
 
+	ret = mana_mr_btree_init(&txq->mr_btree,
+				 MANA_MR_BTREE_PER_QUEUE_N, socket_id);
+	if (ret) {
+		DRV_LOG(ERR, "Failed to init TXQ MR btree");
+		goto fail;
+	}
+
 	DRV_LOG(DEBUG, "idx %u nb_desc %u socket %u txq->desc_ring %p",
 		queue_idx, nb_desc, socket_id, txq->desc_ring);
 
@@ -353,6 +362,8 @@ mana_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 {
 	struct mana_txq *txq = dev->data->tx_queues[qid];
 
+	mana_mr_btree_free(&txq->mr_btree);
+
 	rte_free(txq->desc_ring);
 	rte_free(txq);
 }
@@ -392,6 +403,13 @@ mana_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	rxq->desc_ring_head = 0;
 	rxq->desc_ring_tail = 0;
 
+	ret = mana_mr_btree_init(&rxq->mr_btree,
+				 MANA_MR_BTREE_PER_QUEUE_N, socket_id);
+	if (ret) {
+		DRV_LOG(ERR, "Failed to init RXQ MR btree");
+		goto fail;
+	}
+
 	rxq->priv = priv;
 	rxq->num_desc = nb_desc;
 	rxq->mp = mp;
@@ -410,6 +428,8 @@ mana_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 {
 	struct mana_rxq *rxq = dev->data->rx_queues[qid];
 
+	mana_mr_btree_free(&rxq->mr_btree);
+
 	rte_free(rxq->desc_ring);
 	rte_free(rxq);
 }
drivers/net/mana/mana.h +42 -0

84 lines not on this page · raw message

drivers/net/mana/meson.build +1 -0
index ae6beda5e0..c4a19ad745 100644
@@ -12,6 +12,7 @@ deps += ['pci', 'bus_pci', 'net', 'eal', 'kvargs']
 sources += files(
         'mana.c',
         'mp.c',
+        'mr.c',
 )
 
 libnames = ['ibverbs', 'mana' ]
drivers/net/mana/mp.c +92 -0

110 lines not on this page · raw message

drivers/net/mana/mr.c new file +348 -0

348 lines not on this page · raw message

Signature · 1 line
2.17.1
#28 lore raw

PATCH v9 11/18 net/mana: implement the hardware layer operations

In reply to [email protected]

From: Long Li <[email protected]>

The hardware layer of MANA understands the device queue and doorbell formats. Those functions are implemented for use by packet RX/TX code.

---
Change log:
v2:
Remove unused header files.
Rename a camel case.
v5:
Use RTE_BIT32() instead of defining a new BIT()
v6:
add rte_rmb() after reading owner bits
v8:
fix coding style to function definitions.
use capital letters for all enum names
v9:
Add back RTE_BIT32() in v5 (rebase accident)
Move data definitoins from earlier patch.

 drivers/net/mana/gdma.c      | 301 +++++++++++++++++++++++++++++++++++
 drivers/net/mana/mana.h      | 191 ++++++++++++++++++++++
 drivers/net/mana/meson.build |   1 +
 3 files changed, 493 insertions(+)
 create mode 100644 drivers/net/mana/gdma.c
drivers/net/mana/gdma.c new file +301 -0
new file mode 100644
index 0000000000..3f937d6c93
@@ -0,0 +1,301 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2022 Microsoft Corporation
+ */
+
+#include <ethdev_driver.h>
+#include <rte_io.h>
+
+#include "mana.h"
+
+uint8_t *
+gdma_get_wqe_pointer(struct mana_gdma_queue *queue)
+{
+	uint32_t offset_in_bytes =
+		(queue->head * GDMA_WQE_ALIGNMENT_UNIT_SIZE) &
+		(queue->size - 1);
+
+	DRV_LOG(DEBUG, "txq sq_head %u sq_size %u offset_in_bytes %u",
+		queue->head, queue->size, offset_in_bytes);
+
+	if (offset_in_bytes + GDMA_WQE_ALIGNMENT_UNIT_SIZE > queue->size)
+		DRV_LOG(ERR, "fatal error: offset_in_bytes %u too big",
+			offset_in_bytes);
+
+	return ((uint8_t *)queue->buffer) + offset_in_bytes;
+}
+
+static uint32_t
+write_dma_client_oob(uint8_t *work_queue_buffer_pointer,
+		     const struct gdma_work_request *work_request,
+		     uint32_t client_oob_size)
+{
+	uint8_t *p = work_queue_buffer_pointer;
+
+	struct gdma_wqe_dma_oob *header = (struct gdma_wqe_dma_oob *)p;
+
+	memset(header, 0, sizeof(struct gdma_wqe_dma_oob));
+	header->num_sgl_entries = work_request->num_sgl_elements;
+	header->inline_client_oob_size_in_dwords =
+		client_oob_size / sizeof(uint32_t);
+	header->client_data_unit = work_request->client_data_unit;
+
+	DRV_LOG(DEBUG, "queue buf %p sgl %u oob_h %u du %u oob_buf %p oob_b %u",
+		work_queue_buffer_pointer, header->num_sgl_entries,
+		header->inline_client_oob_size_in_dwords,
+		header->client_data_unit, work_request->inline_oob_data,
+		work_request->inline_oob_size_in_bytes);
+
+	p += sizeof(struct gdma_wqe_dma_oob);
+	if (work_request->inline_oob_data &&
+	    work_request->inline_oob_size_in_bytes > 0) {
+		memcpy(p, work_request->inline_oob_data,
+		       work_request->inline_oob_size_in_bytes);
+		if (client_oob_size > work_request->inline_oob_size_in_bytes)
+			memset(p + work_request->inline_oob_size_in_bytes, 0,
+			       client_oob_size -
+			       work_request->inline_oob_size_in_bytes);
+	}
+
+	return sizeof(struct gdma_wqe_dma_oob) + client_oob_size;
+}
+
+static uint32_t
+write_scatter_gather_list(uint8_t *work_queue_head_pointer,
+			  uint8_t *work_queue_end_pointer,
+			  uint8_t *work_queue_cur_pointer,
+			  struct gdma_work_request *work_request)
+{
+	struct gdma_sgl_element *sge_list;
+	struct gdma_sgl_element dummy_sgl[1];
+	uint8_t *address;
+	uint32_t size;
+	uint32_t num_sge;
+	uint32_t size_to_queue_end;
+	uint32_t sge_list_size;
+
+	DRV_LOG(DEBUG, "work_queue_cur_pointer %p work_request->flags %x",
+		work_queue_cur_pointer, work_request->flags);
+
+	num_sge = work_request->num_sgl_elements;
+	sge_list = work_request->sgl;
+	size_to_queue_end = (uint32_t)(work_queue_end_pointer -
+				       work_queue_cur_pointer);
+
+	if (num_sge == 0) {
+		/* Per spec, the case of an empty SGL should be handled as
+		 * follows to avoid corrupted WQE errors:
+		 * Write one dummy SGL entry
+		 * Set the address to 1, leave the rest as 0
+		 */
+		dummy_sgl[num_sge].address = 1;
+		dummy_sgl[num_sge].size = 0;
+		dummy_sgl[num_sge].memory_key = 0;
+		num_sge++;
+		sge_list = dummy_sgl;
+	}
+
+	sge_list_size = 0;
+	{
+		address = (uint8_t *)sge_list;
+		size = sizeof(struct gdma_sgl_element) * num_sge;
+		if (size_to_queue_end < size) {
+			memcpy(work_queue_cur_pointer, address,
+			       size_to_queue_end);
+			work_queue_cur_pointer = work_queue_head_pointer;
+			address += size_to_queue_end;
+			size -= size_to_queue_end;
+		}
+
+		memcpy(work_queue_cur_pointer, address, size);
+		sge_list_size = size;
+	}
+
+	DRV_LOG(DEBUG, "sge %u address 0x%" PRIx64 " size %u key %u list_s %u",
+		num_sge, sge_list->address, sge_list->size,
+		sge_list->memory_key, sge_list_size);
+
+	return sge_list_size;
+}
+
+/*
+ * Post a work request to queue.
+ */
+int
+gdma_post_work_request(struct mana_gdma_queue *queue,
+		       struct gdma_work_request *work_req,
+		       struct gdma_posted_wqe_info *wqe_info)
+{
+	uint32_t client_oob_size =
+		work_req->inline_oob_size_in_bytes >
+				INLINE_OOB_SMALL_SIZE_IN_BYTES ?
+			INLINE_OOB_LARGE_SIZE_IN_BYTES :
+			INLINE_OOB_SMALL_SIZE_IN_BYTES;
+
+	uint32_t sgl_data_size = sizeof(struct gdma_sgl_element) *
+			RTE_MAX((uint32_t)1, work_req->num_sgl_elements);
+	uint32_t wqe_size =
+		RTE_ALIGN(sizeof(struct gdma_wqe_dma_oob) +
+				client_oob_size + sgl_data_size,
+			  GDMA_WQE_ALIGNMENT_UNIT_SIZE);
+	uint8_t *wq_buffer_pointer;
+	uint32_t queue_free_units = queue->count - (queue->head - queue->tail);
+
+	if (wqe_size / GDMA_WQE_ALIGNMENT_UNIT_SIZE > queue_free_units) {
+		DRV_LOG(DEBUG, "WQE size %u queue count %u head %u tail %u",
+			wqe_size, queue->count, queue->head, queue->tail);
+		return -EBUSY;
+	}
+
+	DRV_LOG(DEBUG, "client_oob_size %u sgl_data_size %u wqe_size %u",
+		client_oob_size, sgl_data_size, wqe_size);
+
+	if (wqe_info) {
+		wqe_info->wqe_index =
+			((queue->head * GDMA_WQE_ALIGNMENT_UNIT_SIZE) &
+			 (queue->size - 1)) / GDMA_WQE_ALIGNMENT_UNIT_SIZE;
+		wqe_info->unmasked_queue_offset = queue->head;
+		wqe_info->wqe_size_in_bu =
+			wqe_size / GDMA_WQE_ALIGNMENT_UNIT_SIZE;
+	}
+
+	wq_buffer_pointer = gdma_get_wqe_pointer(queue);
+	wq_buffer_pointer += write_dma_client_oob(wq_buffer_pointer, work_req,
+						  client_oob_size);
+	if (wq_buffer_pointer >= ((uint8_t *)queue->buffer) + queue->size)
+		wq_buffer_pointer -= queue->size;
+
+	write_scatter_gather_list((uint8_t *)queue->buffer,
+				  (uint8_t *)queue->buffer + queue->size,
+				  wq_buffer_pointer, work_req);
+
+	queue->head += wqe_size / GDMA_WQE_ALIGNMENT_UNIT_SIZE;
+
+	return 0;
+}
+
+union gdma_doorbell_entry {
+	uint64_t     as_uint64;
+
+	struct {
+		uint64_t id	  : 24;
+		uint64_t reserved    : 8;
+		uint64_t tail_ptr    : 31;
+		uint64_t arm	 : 1;
+	} cq;
+
+	struct {
+		uint64_t id	  : 24;
+		uint64_t wqe_cnt     : 8;
+		uint64_t tail_ptr    : 32;
+	} rq;
+
+	struct {
+		uint64_t id	  : 24;
+		uint64_t reserved    : 8;
+		uint64_t tail_ptr    : 32;
+	} sq;
+
+	struct {
+		uint64_t id	  : 16;
+		uint64_t reserved    : 16;
+		uint64_t tail_ptr    : 31;
+		uint64_t arm	 : 1;
+	} eq;
+}; /* HW DATA */
+
+#define DOORBELL_OFFSET_SQ      0x0
+#define DOORBELL_OFFSET_RQ      0x400
+#define DOORBELL_OFFSET_CQ      0x800
+#define DOORBELL_OFFSET_EQ      0xFF8
+
+/*
+ * Write to hardware doorbell to notify new activity.
+ */
+int
+mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
+		   uint32_t queue_id, uint32_t tail)
+{
+	uint8_t *addr = db_page;
+	union gdma_doorbell_entry e = {};
+
+	switch (queue_type) {
+	case GDMA_QUEUE_SEND:
+		e.sq.id = queue_id;
+		e.sq.tail_ptr = tail;
+		addr += DOORBELL_OFFSET_SQ;
+		break;
+
+	case GDMA_QUEUE_RECEIVE:
+		e.rq.id = queue_id;
+		e.rq.tail_ptr = tail;
+		e.rq.wqe_cnt = 1;
+		addr += DOORBELL_OFFSET_RQ;
+		break;
+
+	case GDMA_QUEUE_COMPLETION:
+		e.cq.id = queue_id;
+		e.cq.tail_ptr = tail;
+		e.cq.arm = 1;
+		addr += DOORBELL_OFFSET_CQ;
+		break;
+
+	default:
+		DRV_LOG(ERR, "Unsupported queue type %d", queue_type);
+		return -1;
+	}
+
+	/* Ensure all writes are done before ringing doorbell */
+	rte_wmb();
+
+	DRV_LOG(DEBUG, "db_page %p addr %p queue_id %u type %u tail %u",
+		db_page, addr, queue_id, queue_type, tail);
+
+	rte_write64(e.as_uint64, addr);
+	return 0;
+}
+
+/*
+ * Poll completion queue for completions.
+ */
+int
+gdma_poll_completion_queue(struct mana_gdma_queue *cq, struct gdma_comp *comp)
+{
+	struct gdma_hardware_completion_entry *cqe;
+	uint32_t head = cq->head % cq->count;
+	uint32_t new_owner_bits, old_owner_bits;
+	uint32_t cqe_owner_bits;
+	struct gdma_hardware_completion_entry *buffer = cq->buffer;
+
+	cqe = &buffer[head];
+	new_owner_bits = (cq->head / cq->count) & COMPLETION_QUEUE_OWNER_MASK;
+	old_owner_bits = (cq->head / cq->count - 1) &
+				COMPLETION_QUEUE_OWNER_MASK;
+	cqe_owner_bits = cqe->owner_bits;
+
+	DRV_LOG(DEBUG, "comp cqe bits 0x%x owner bits 0x%x",
+		cqe_owner_bits, old_owner_bits);
+
+	if (cqe_owner_bits == old_owner_bits)
+		return 0; /* No new entry */
+
+	if (cqe_owner_bits != new_owner_bits) {
+		DRV_LOG(ERR, "CQ overflowed, ID %u cqe 0x%x new 0x%x",
+			cq->id, cqe_owner_bits, new_owner_bits);
+		return -1;
+	}
+
+	/* Ensure checking owner bits happens before reading from CQE */
+	rte_rmb();
+
+	comp->work_queue_number = cqe->wq_num;
+	comp->send_work_queue = cqe->is_sq;
+
+	memcpy(comp->completion_data, cqe->dma_client_data, GDMA_COMP_DATA_SIZE);
+
+	cq->head++;
+
+	DRV_LOG(DEBUG, "comp new 0x%x old 0x%x cqe 0x%x wq %u sq %u head %u",
+		new_owner_bits, old_owner_bits, cqe_owner_bits,
+		comp->work_queue_number, comp->send_work_queue, cq->head);
+	return 1;
+}
drivers/net/mana/mana.h +191 -0

215 lines not on this page · raw message

drivers/net/mana/meson.build +1 -0
index c4a19ad745..dea8b97afb 100644
@@ -10,6 +10,7 @@ endif
 deps += ['pci', 'bus_pci', 'net', 'eal', 'kvargs']
 
 sources += files(
+        'gdma.c',
         'mana.c',
         'mp.c',
         'mr.c',
Signature · 1 line
2.17.1
#29 lore raw

Re: [Patch v9 11/18] net/mana: implement the hardware layer operations

Quoted 7 lines · On 9/24/2022 3:45 AM, [email protected] wrote:

From: Long Li <[email protected]>

The hardware layer of MANA understands the device queue and doorbell formats. Those functions are implemented for use by packet RX/TX code.

<...>

drivers/net/mana/gdma.c line 209

Quoted 5 lines
drivers/net/mana/gdma.c new file +5 -0
+
+#define DOORBELL_OFFSET_SQ      0x0
+#define DOORBELL_OFFSET_RQ      0x400
+#define DOORBELL_OFFSET_CQ      0x800
+#define DOORBELL_OFFSET_EQ      0xFF8

Instead above can be enums if you prefer. This is only to reference previous comment on making PCI IDs enum.

#30 lore raw

PATCH v9 12/18 net/mana: start/stop Tx queues

In reply to [email protected]

From: Long Li <[email protected]>

MANA allocate device queues through the IB layer when starting Tx queues. When device is stopped all the queues are unmapped and freed.

---
Change log:
v2:
Add prefix mana_ to all function names.
Remove unused header files.
v8:
fix coding style to function definitions.
v9:
move some data definitions from earlier patch.

 doc/guides/nics/features/mana.ini |   1 +
 drivers/net/mana/mana.h           |  11 ++
 drivers/net/mana/meson.build      |   1 +
 drivers/net/mana/tx.c             | 166 ++++++++++++++++++++++++++++++
 4 files changed, 179 insertions(+)
 create mode 100644 drivers/net/mana/tx.c
doc/guides/nics/features/mana.ini +1 -0
index a59c21cc10..821443b292 100644
@@ -7,6 +7,7 @@
 Link status          = P
 Linux                = Y
 Multiprocess aware   = Y
+Queue start/stop     = Y
 Removal event        = Y
 RSS hash             = Y
 Speed capabilities   = P
drivers/net/mana/mana.h +11 -0
index f4fb6e8a37..0b0c6ad122 100644
@@ -293,6 +293,13 @@ struct mana_gdma_queue {
 struct mana_txq {
 	struct mana_priv *priv;
 	uint32_t num_desc;
+	struct ibv_cq *cq;
+	struct ibv_qp *qp;
+
+	struct mana_gdma_queue gdma_sq;
+	struct mana_gdma_queue gdma_cq;
+
+	uint32_t tx_vp_offset;
 
 	/* For storing pending requests */
 	struct mana_txq_desc *desc_ring;
@@ -354,6 +361,10 @@ uint16_t mana_tx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,
 int gdma_poll_completion_queue(struct mana_gdma_queue *cq,
 			       struct gdma_comp *comp);
 
+int mana_start_tx_queues(struct rte_eth_dev *dev);
+
+int mana_stop_tx_queues(struct rte_eth_dev *dev);
+
 struct mana_mr_cache *mana_find_pmd_mr(struct mana_mr_btree *local_tree,
 				       struct mana_priv *priv,
 				       struct rte_mbuf *mbuf);
drivers/net/mana/meson.build +1 -0
index dea8b97afb..2ffb76a36a 100644
@@ -14,6 +14,7 @@ sources += files(
         'mana.c',
         'mp.c',
         'mr.c',
+        'tx.c',
 )
 
 libnames = ['ibverbs', 'mana' ]
drivers/net/mana/tx.c new file +166 -0

166 lines not on this page · raw message

Signature · 1 line
2.17.1
#31 lore raw

PATCH v9 13/18 net/mana: start/stop Rx queues

In reply to [email protected]

From: Long Li <[email protected]>

MANA allocates device queues through the IB layer when starting Rx queues. When device is stopped all the queues are unmapped and freed.

---
Change log:
v2:
Add prefix mana_ to all function names.
Remove unused header files.
v4:
Move defition "uint32_t i" from inside "for ()" to outside v8:
Fix coding style to function definitions.
v9:
Move data definitions from earlier patch.

 drivers/net/mana/mana.h      |  18 ++
 drivers/net/mana/meson.build |   1 +
 drivers/net/mana/rx.c        | 354 +++++++++++++++++++++++++++++++++++
 3 files changed, 373 insertions(+)
 create mode 100644 drivers/net/mana/rx.c
drivers/net/mana/mana.h +18 -0
index 0b0c6ad122..5312c2f93c 100644
@@ -254,6 +254,8 @@ struct mana_priv {
 	struct ibv_context *ib_ctx;
 	struct ibv_pd *ib_pd;
 	struct ibv_pd *ib_parent_pd;
+	struct ibv_rwq_ind_table *ind_table;
+	struct ibv_qp *rwq_qp;
 	void *db_page;
 	struct rte_eth_rss_conf rss_conf;
 	struct rte_intr_handle *intr_handle;
@@ -279,6 +281,13 @@ struct mana_rxq_desc {
 	uint32_t wqe_size_in_bu;
 };
 
+struct mana_stats {
+	uint64_t packets;
+	uint64_t bytes;
+	uint64_t errors;
+	uint64_t nombuf;
+};
+
 struct mana_gdma_queue {
 	void *buffer;
 	uint32_t count;	/* in entries */
@@ -317,6 +326,8 @@ struct mana_rxq {
 	struct mana_priv *priv;
 	uint32_t num_desc;
 	struct rte_mempool *mp;
+	struct ibv_cq *cq;
+	struct ibv_wq *wq;
 
 	/* For storing pending requests */
 	struct mana_rxq_desc *desc_ring;
@@ -326,6 +337,10 @@ struct mana_rxq {
 	 */
 	uint32_t desc_ring_head, desc_ring_tail;
 
+	struct mana_gdma_queue gdma_rq;
+	struct mana_gdma_queue gdma_cq;
+
+	struct mana_stats stats;
 	struct mana_mr_btree mr_btree;
 
 	unsigned int socket;
@@ -346,6 +361,7 @@ extern int mana_logtype_init;
 
 int mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
 		       uint32_t queue_id, uint32_t tail);
+int mana_rq_ring_doorbell(struct mana_rxq *rxq);
 
 int gdma_post_work_request(struct mana_gdma_queue *queue,
 			   struct gdma_work_request *work_req,
@@ -361,8 +377,10 @@ uint16_t mana_tx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,
 int gdma_poll_completion_queue(struct mana_gdma_queue *cq,
 			       struct gdma_comp *comp);
 
+int mana_start_rx_queues(struct rte_eth_dev *dev);
 int mana_start_tx_queues(struct rte_eth_dev *dev);
 
+int mana_stop_rx_queues(struct rte_eth_dev *dev);
 int mana_stop_tx_queues(struct rte_eth_dev *dev);
 
 struct mana_mr_cache *mana_find_pmd_mr(struct mana_mr_btree *local_tree,
drivers/net/mana/meson.build +1 -0
index 2ffb76a36a..bdf526e846 100644
@@ -14,6 +14,7 @@ sources += files(
         'mana.c',
         'mp.c',
         'mr.c',
+        'rx.c',
         'tx.c',
 )
 
drivers/net/mana/rx.c new file +354 -0

354 lines not on this page · raw message

Signature · 1 line
2.17.1
#32 lore raw

PATCH v9 14/18 net/mana: receive packets

In reply to [email protected]

From: Long Li <[email protected]>

With all the RX queues created, MANA can use those queues to receive packets.

---
Change log:
v2:
Add mana_ to all function names.
Rename a camel case.
v8:
Fix coding style to function definitions.

 doc/guides/nics/features/mana.ini |   2 +
 drivers/net/mana/mana.c           |   2 +
 drivers/net/mana/mana.h           |  37 +++++++++++
 drivers/net/mana/mp.c             |   2 +
 drivers/net/mana/rx.c             | 105 ++++++++++++++++++++++++++++++
 5 files changed, 148 insertions(+)
doc/guides/nics/features/mana.ini +2 -0
index 821443b292..fdbf22d335 100644
@@ -6,6 +6,8 @@
 [Features]
 Link status          = P
 Linux                = Y
+L3 checksum offload  = Y
+L4 checksum offload  = Y
 Multiprocess aware   = Y
 Queue start/stop     = Y
 Removal event        = Y
drivers/net/mana/mana.c +2 -0
index a3c949d408..51aa01a642 100644
@@ -991,6 +991,8 @@ mana_pci_probe_mac(struct rte_pci_device *pci_dev,
 				/* fd is no not used after mapping doorbell */
 				close(fd);
 
+				eth_dev->rx_pkt_burst = mana_rx_burst;
+
 				rte_spinlock_lock(&mana_shared_data->lock);
 				mana_shared_data->secondary_cnt++;
 				mana_local_data.secondary_cnt++;
drivers/net/mana/mana.h +37 -0
index 5312c2f93c..ef0743df2d 100644
@@ -177,6 +177,11 @@ struct gdma_work_request {
 
 enum mana_cqe_type {
 	CQE_INVALID                     = 0,
+
+	CQE_RX_OKAY                     = 1,
+	CQE_RX_COALESCED_4              = 2,
+	CQE_RX_OBJECT_FENCE             = 3,
+	CQE_RX_TRUNCATED                = 4,
 };
 
 struct mana_cqe_header {
@@ -201,6 +206,35 @@ struct mana_cqe_header {
 	(NDIS_HASH_TCP_IPV4 | NDIS_HASH_UDP_IPV4 | NDIS_HASH_TCP_IPV6 |      \
 	 NDIS_HASH_UDP_IPV6 | NDIS_HASH_TCP_IPV6_EX | NDIS_HASH_UDP_IPV6_EX)
 
+struct mana_rx_comp_per_packet_info {
+	uint32_t packet_length	: 16;
+	uint32_t reserved0	: 16;
+	uint32_t reserved1;
+	uint32_t packet_hash;
+}; /* HW DATA */
+#define RX_COM_OOB_NUM_PACKETINFO_SEGMENTS 4
+
+struct mana_rx_comp_oob {
+	struct mana_cqe_header cqe_hdr;
+
+	uint32_t rx_vlan_id				: 12;
+	uint32_t rx_vlan_tag_present			: 1;
+	uint32_t rx_outer_ip_header_checksum_succeeded	: 1;
+	uint32_t rx_outer_ip_header_checksum_failed	: 1;
+	uint32_t reserved				: 1;
+	uint32_t rx_hash_type				: 9;
+	uint32_t rx_ip_header_checksum_succeeded	: 1;
+	uint32_t rx_ip_header_checksum_failed		: 1;
+	uint32_t rx_tcp_checksum_succeeded		: 1;
+	uint32_t rx_tcp_checksum_failed			: 1;
+	uint32_t rx_udp_checksum_succeeded		: 1;
+	uint32_t rx_udp_checksum_failed			: 1;
+	uint32_t reserved1				: 1;
+	struct mana_rx_comp_per_packet_info
+		packet_info[RX_COM_OOB_NUM_PACKETINFO_SEGMENTS];
+	uint32_t received_wqe_offset;
+}; /* HW DATA */
+
 struct gdma_wqe_dma_oob {
 	uint32_t reserved:24;
 	uint32_t last_v_bytes:8;
@@ -368,6 +402,9 @@ int gdma_post_work_request(struct mana_gdma_queue *queue,
 			   struct gdma_posted_wqe_info *wqe_info);
 uint8_t *gdma_get_wqe_pointer(struct mana_gdma_queue *queue);
 
+uint16_t mana_rx_burst(void *dpdk_rxq, struct rte_mbuf **rx_pkts,
+		       uint16_t pkts_n);
+
 uint16_t mana_rx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,
 			       uint16_t pkts_n);
 
drivers/net/mana/mp.c +2 -0
index a3b5ede559..feda30623a 100644
@@ -141,6 +141,8 @@ mana_mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
 	case MANA_MP_REQ_START_RXTX:
 		DRV_LOG(INFO, "Port %u starting datapath", dev->data->port_id);
 
+		dev->rx_pkt_burst = mana_rx_burst;
+
 		rte_mb();
 
 		res->result = 0;
drivers/net/mana/rx.c +105 -0

108 lines not on this page · raw message

Signature · 1 line
2.17.1
#33 lore raw

Re: [Patch v9 14/18] net/mana: receive packets

Quoted 7 lines · On 9/24/2022 3:45 AM, [email protected] wrote:

From: Long Li <[email protected]>

With all the RX queues created, MANA can use those queues to receive packets.

<...>

doc/guides/nics/features/mana.ini line 10

Quoted 10 lines
doc/guides/nics/features/mana.ini +2 -0
index 821443b292..fdbf22d335 100644
@@ -6,6 +6,8 @@
  [Features]
  Link status          = P
  Linux                = Y
+L3 checksum offload  = Y
+L4 checksum offload  = Y

While adding new features, can you please keep the order in the 'doc/guides/nics/features/default.ini' file.

#34 lore raw

PATCH v9 15/18 net/mana: send packets

In reply to [email protected]

From: Long Li <[email protected]>

With all the TX queues created, MANA can send packets over those queues.

---
Change log:
v2: rename all camel cases.
v7: return the correct number of packets sent
v8:
fix coding style to function definitions.
change enum names to use capital letters.

 doc/guides/nics/features/mana.ini |   1 +
 drivers/net/mana/mana.c           |   1 +
 drivers/net/mana/mana.h           |  66 ++++++++
 drivers/net/mana/mp.c             |   1 +
 drivers/net/mana/tx.c             | 248 ++++++++++++++++++++++++++++++
 5 files changed, 317 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
index fdbf22d335..7922816d66 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Free Tx mbuf on demand = Y
 Link status          = P
 Linux                = Y
 L3 checksum offload  = Y
drivers/net/mana/mana.c +1 -0
index 51aa01a642..d0214725e6 100644
@@ -991,6 +991,7 @@ mana_pci_probe_mac(struct rte_pci_device *pci_dev,
 				/* fd is no not used after mapping doorbell */
 				close(fd);
 
+				eth_dev->tx_pkt_burst = mana_tx_burst;
 				eth_dev->rx_pkt_burst = mana_rx_burst;
 
 				rte_spinlock_lock(&mana_shared_data->lock);
drivers/net/mana/mana.h +66 -0

96 lines not on this page · raw message

drivers/net/mana/mp.c +1 -0
index feda30623a..92432c431d 100644
@@ -141,6 +141,7 @@ mana_mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
 	case MANA_MP_REQ_START_RXTX:
 		DRV_LOG(INFO, "Port %u starting datapath", dev->data->port_id);
 
+		dev->tx_pkt_burst = mana_tx_burst;
 		dev->rx_pkt_burst = mana_rx_burst;
 
 		rte_mb();
drivers/net/mana/tx.c +248 -0

251 lines not on this page · raw message

Signature · 1 line
2.17.1
#35 lore raw

Re: [Patch v9 15/18] net/mana: send packets

Quoted 26 lines · On 9/24/2022 3:45 AM, [email protected] wrote:

From: Long Li <[email protected]>

With all the TX queues created, MANA can send packets over those queues.

---
Change log:
v2: rename all camel cases.
v7: return the correct number of packets sent
v8:
fix coding style to function definitions.
change enum names to use capital letters.

  doc/guides/nics/features/mana.ini |   1 +
  drivers/net/mana/mana.c           |   1 +
  drivers/net/mana/mana.h           |  66 ++++++++
  drivers/net/mana/mp.c             |   1 +
  drivers/net/mana/tx.c             | 248 ++++++++++++++++++++++++++++++
  5 files changed, 317 insertions(+)
doc/guides/nics/features/mana.ini +0 -0
index fdbf22d335..7922816d66 100644

doc/guides/nics/features/mana.ini line 7

Quoted 4 lines
doc/guides/nics/features/mana.ini +1 -0
@@ -4,6 +4,7 @@
  ; Refer to default.ini for the full list of available PMD features.
  ;
  [Features]
+Free Tx mbuf on demand = Y

Isn't this requires driver to implement 'tx_done_cleanup()' dev_ops, as far as I can see driver doesn't support this.

#36 lore raw

PATCH v9 16/18 net/mana: start/stop device

In reply to [email protected]

From: Long Li <[email protected]>

Add support for starting/stopping the device.

---
Change log:
v2:
Use spinlock for memory registration cache. Add prefix mana_ to all function names.
v6:
Roll back device state on error in mana_dev_start()

 drivers/net/mana/mana.c | 77 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)
drivers/net/mana/mana.c +77 -0
index d0214725e6..c43212950f 100644
@@ -105,6 +105,81 @@ mana_dev_configure(struct rte_eth_dev *dev)
 
 static int mana_intr_uninstall(struct mana_priv *priv);
 
+static int
+mana_dev_start(struct rte_eth_dev *dev)
+{
+	int ret;
+	struct mana_priv *priv = dev->data->dev_private;
+
+	rte_spinlock_init(&priv->mr_btree_lock);
+	ret = mana_mr_btree_init(&priv->mr_btree, MANA_MR_BTREE_CACHE_N,
+				 dev->device->numa_node);
+	if (ret) {
+		DRV_LOG(ERR, "Failed to init device MR btree %d", ret);
+		return ret;
+	}
+
+	ret = mana_start_tx_queues(dev);
+	if (ret) {
+		DRV_LOG(ERR, "failed to start tx queues %d", ret);
+		goto failed_tx;
+	}
+
+	ret = mana_start_rx_queues(dev);
+	if (ret) {
+		DRV_LOG(ERR, "failed to start rx queues %d", ret);
+		goto failed_rx;
+	}
+
+	rte_wmb();
+
+	dev->tx_pkt_burst = mana_tx_burst;
+	dev->rx_pkt_burst = mana_rx_burst;
+
+	DRV_LOG(INFO, "TX/RX queues have started");
+
+	/* Enable datapath for secondary processes */
+	mana_mp_req_on_rxtx(dev, MANA_MP_REQ_START_RXTX);
+
+	return 0;
+
+failed_rx:
+	mana_stop_tx_queues(dev);
+
+failed_tx:
+	mana_mr_btree_free(&priv->mr_btree);
+
+	return ret;
+}
+
+static int
+mana_dev_stop(struct rte_eth_dev *dev __rte_unused)
+{
+	int ret;
+
+	dev->tx_pkt_burst = mana_tx_burst_removed;
+	dev->rx_pkt_burst = mana_rx_burst_removed;
+
+	/* Stop datapath on secondary processes */
+	mana_mp_req_on_rxtx(dev, MANA_MP_REQ_STOP_RXTX);
+
+	rte_wmb();
+
+	ret = mana_stop_tx_queues(dev);
+	if (ret) {
+		DRV_LOG(ERR, "failed to stop tx queues");
+		return ret;
+	}
+
+	ret = mana_stop_rx_queues(dev);
+	if (ret) {
+		DRV_LOG(ERR, "failed to stop tx queues");
+		return ret;
+	}
+
+	return 0;
+}
+
 static int
 mana_dev_close(struct rte_eth_dev *dev)
 {
@@ -453,6 +528,8 @@ mana_dev_link_update(struct rte_eth_dev *dev,
 
 static const struct eth_dev_ops mana_dev_ops = {
 	.dev_configure		= mana_dev_configure,
+	.dev_start		= mana_dev_start,
+	.dev_stop		= mana_dev_stop,
 	.dev_close		= mana_dev_close,
 	.dev_infos_get		= mana_dev_info_get,
 	.txq_info_get		= mana_dev_tx_queue_info,
Signature · 1 line
2.17.1
#37 lore raw

PATCH v9 17/18 net/mana: report queue stats

In reply to [email protected]

From: Long Li <[email protected]>

Report packet statistics.

---
Change log:
v5:
Fixed calculation of stats packets/bytes/errors by adding them over the queue stats. v8:
Fixed coding style on function definitions.

 doc/guides/nics/features/mana.ini |  1 +
 drivers/net/mana/mana.c           | 77 +++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
index 7922816d66..81ebc9c365 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Basic stats          = Y
 Free Tx mbuf on demand = Y
 Link status          = P
 Linux                = Y
drivers/net/mana/mana.c +77 -0

92 lines not on this page · raw message

Signature · 1 line
2.17.1
#38 lore raw

PATCH v9 18/18 net/mana: support Rx interrupts

In reply to [email protected]

From: Long Li <[email protected]>

mana can receive Rx interrupts from kernel through RDMA verbs interface. Implement Rx interrupts in the driver.

---
Change log:
v5:
New patch added to the series
v8:
Fix coding style on function definitions.

 doc/guides/nics/features/mana.ini |   1 +
 drivers/net/mana/gdma.c           |  10 +--
 drivers/net/mana/mana.c           | 128 ++++++++++++++++++++++++++----
 drivers/net/mana/mana.h           |   9 ++-
 drivers/net/mana/rx.c             |  94 +++++++++++++++++++---
 drivers/net/mana/tx.c             |   3 +-
 6 files changed, 211 insertions(+), 34 deletions(-)
doc/guides/nics/features/mana.ini +1 -0
index 81ebc9c365..5fb62ea85d 100644
@@ -14,6 +14,7 @@ Multiprocess aware   = Y
 Queue start/stop     = Y
 Removal event        = Y
 RSS hash             = Y
+Rx interrupt         = Y
 Speed capabilities   = P
 Usage doc            = Y
 x86-64               = Y
drivers/net/mana/gdma.c +5 -5
index 3f937d6c93..c67c5af2f9 100644
@@ -213,7 +213,7 @@ union gdma_doorbell_entry {
  */
 int
 mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
-		   uint32_t queue_id, uint32_t tail)
+		   uint32_t queue_id, uint32_t tail, uint8_t arm)
 {
 	uint8_t *addr = db_page;
 	union gdma_doorbell_entry e = {};
@@ -228,14 +228,14 @@ mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
 	case GDMA_QUEUE_RECEIVE:
 		e.rq.id = queue_id;
 		e.rq.tail_ptr = tail;
-		e.rq.wqe_cnt = 1;
+		e.rq.wqe_cnt = arm;
 		addr += DOORBELL_OFFSET_RQ;
 		break;
 
 	case GDMA_QUEUE_COMPLETION:
 		e.cq.id = queue_id;
 		e.cq.tail_ptr = tail;
-		e.cq.arm = 1;
+		e.cq.arm = arm;
 		addr += DOORBELL_OFFSET_CQ;
 		break;
 
@@ -247,8 +247,8 @@ mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
 	/* Ensure all writes are done before ringing doorbell */
 	rte_wmb();
 
-	DRV_LOG(DEBUG, "db_page %p addr %p queue_id %u type %u tail %u",
-		db_page, addr, queue_id, queue_type, tail);
+	DRV_LOG(DEBUG, "db_page %p addr %p queue_id %u type %u tail %u arm %u",
+		db_page, addr, queue_id, queue_type, tail, arm);
 
 	rte_write64(e.as_uint64, addr);
 	return 0;
drivers/net/mana/mana.c +113 -15

205 lines not on this page · raw message

drivers/net/mana/mana.h +7 -2
index 9c576a82fa..14d813466e 100644
@@ -425,6 +425,7 @@ struct mana_rxq {
 	uint32_t num_desc;
 	struct rte_mempool *mp;
 	struct ibv_cq *cq;
+	struct ibv_comp_channel *channel;
 	struct ibv_wq *wq;
 
 	/* For storing pending requests */
@@ -458,8 +459,8 @@ extern int mana_logtype_init;
 #define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>")
 
 int mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
-		       uint32_t queue_id, uint32_t tail);
-int mana_rq_ring_doorbell(struct mana_rxq *rxq);
+		       uint32_t queue_id, uint32_t tail, uint8_t arm);
+int mana_rq_ring_doorbell(struct mana_rxq *rxq, uint8_t arm);
 
 int gdma_post_work_request(struct mana_gdma_queue *queue,
 			   struct gdma_work_request *work_req,
@@ -539,4 +540,8 @@ void mana_mp_req_on_rxtx(struct rte_eth_dev *dev, enum mana_mp_req_type type);
 void *mana_alloc_verbs_buf(size_t size, void *data);
 void mana_free_verbs_buf(void *ptr, void *data __rte_unused);
 
+int mana_rx_intr_enable(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int mana_rx_intr_disable(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int mana_fd_set_non_blocking(int fd);
+
 #endif
drivers/net/mana/rx.c +83 -11

145 lines not on this page · raw message

drivers/net/mana/tx.c +2 -1
index 0884681c30..a92d895e54 100644
@@ -406,7 +406,8 @@ mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		ret = mana_ring_doorbell(db_page, GDMA_QUEUE_SEND,
 					 txq->gdma_sq.id,
 					 txq->gdma_sq.head *
-						GDMA_WQE_ALIGNMENT_UNIT_SIZE);
+						GDMA_WQE_ALIGNMENT_UNIT_SIZE,
+					 0);
 	if (ret)
 		DRV_LOG(ERR, "mana_ring_doorbell failed ret %d", ret);
 
Signature · 1 line
2.17.1
#39 lore raw
In reply to [email protected]
Quoted 28 lines · On 9/24/2022 3:45 AM, [email protected] wrote:

From: Long Li <[email protected]>

MANA is a network interface card to be used in the Azure cloud environment. MANA provides safe access to user memory through memory registration. It has IOMMU built into the hardware.

MANA uses IB verbs and RDMA layer to configure hardware resources. It requires the corresponding RDMA kernel-mode and user-mode drivers.

The MANA RDMA kernel-mode driver is being reviewed at:
https://patchwork.kernel.org/project/netdevbpf/list/?series=678843&state=*

The MANA RDMA user-mode driver is being reviewed at:
https://github.com/linux-rdma/rdma-core/pull/1177

Long Li (18):
net/mana: add basic driver with build environment and doc net/mana: device configuration and stop net/mana: report supported ptypes
net/mana: support link update
net/mana: support device removal interrupts net/mana: report device info
net/mana: configure RSS
net/mana: configure Rx queues
net/mana: configure Tx queues
net/mana: implement memory registration

Quoted 9 lines

net/mana: implement the hardware layer operations net/mana: start/stop Tx queues
net/mana: start/stop Rx queues
net/mana: receive packets
net/mana: send packets
net/mana: start/stop device
net/mana: report queue stats
net/mana: support Rx interrupts

Hi Long,

Driver looks good, only I put a few minor comments, can you please check them?

Thanks,
ferruh

#40 lore raw
Quoted 77 lines

Subject: Re: [Patch v9 00/18] Introduce Microsoft Azure Network Adatper (MANA) PMD

Quoted 4 lines · On 9/24/2022 3:45 AM, [email protected] wrote:

From: Long Li <[email protected]>

MANA is a network interface card to be used in the Azure cloud

environment.

Quoted 8 lines

MANA provides safe access to user memory through memory registration. It has IOMMU built into the hardware.

MANA uses IB verbs and RDMA layer to configure hardware resources. It requires the corresponding RDMA kernel-mode and user-mode drivers.

The MANA RDMA kernel-mode driver is being reviewed at:

https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatc

Quoted 1 line

hwork.kernel.org%2Fproject%2Fnetdevbpf%2Flist%2F%3Fseries%3D678843 %26s

Quoted 1 line

tate%3D*&amp;data=05%7C01%7Clongli%40microsoft.com%7Ccfd942f49229 4bbc3

Quoted 1 line

5f208daa63110f7%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C6380 05026

Quoted 1 line

942011972%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIj oiV2luMzIi

Quoted 1 line

LCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=DnuV 1co%2F7ir

Quoted 4 lines

0MtjAlV17aDr9MyswVos8vcoOJfRpIxg%3D&amp;reserved=0

The MANA RDMA user-mode driver is being reviewed at:

https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith

Quoted 1 line

ub.com%2Flinux-rdma%2Frdma-

core%2Fpull%2F1177&amp;data=05%7C01%7Clongl

Quoted 1 line

i%40microsoft.com%7Ccfd942f492294bbc35f208daa63110f7%7C72f988bf86f1 41a

Quoted 1 line

f91ab2d7cd011db47%7C1%7C0%7C638005026942051727%7CUnknown%7CT WFpbGZsb3d

Quoted 1 line

8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0% 3D%7C

Quoted 1 line

3000%7C%7C%7C&amp;sdata=CgggHkL2gGJmhNeZ4Bi5mZJPZC76pR7o8bB% 2BKT6qcvY%

Quoted 14 lines

3D&amp;reserved=0

Long Li (18):
net/mana: add basic driver with build environment and doc net/mana: device configuration and stop net/mana: report supported ptypes
net/mana: support link update
net/mana: support device removal interrupts net/mana: report device info
net/mana: configure RSS
net/mana: configure Rx queues
net/mana: configure Tx queues
net/mana: implement memory registration

Quoted 9 lines

net/mana: implement the hardware layer operations net/mana: start/stop Tx queues
net/mana: start/stop Rx queues
net/mana: receive packets
net/mana: send packets
net/mana: start/stop device
net/mana: report queue stats
net/mana: support Rx interrupts

Quoted 7 lines

Hi Long,

Driver looks good, only I put a few minor comments, can you please check them?

Thanks,
ferruh

Hi Ferruh,

I will send v10 to address all the comments.

Thanks,
Long

#41 lore raw

v10 cover Introduce Microsoft Azure Network Adatper (MANA) PMD

In reply to [email protected]

From: Long Li <[email protected]>

MANA is a network interface card to be used in the Azure cloud environment. MANA provides safe access to user memory through memory registration. It has IOMMU built into the hardware.

MANA uses IB verbs and RDMA layer to configure hardware resources. It requires the corresponding RDMA kernel-mode and user-mode drivers.

The MANA RDMA kernel-mode driver is being reviewed at:
https://patchwork.kernel.org/project/netdevbpf/list/?series=678843&state=*

The MANA RDMA user-mode driver is being reviewed at:
https://github.com/linux-rdma/rdma-core/pull/1177

Long Li (18):
net/mana: add basic driver with build environment and doc net/mana: device configuration and stop net/mana: report supported ptypes
net/mana: support link update
net/mana: support device removal interrupts net/mana: report device info
net/mana: configure RSS
net/mana: configure Rx queues
net/mana: configure Tx queues
net/mana: implement memory registration net/mana: implement the hardware layer operations net/mana: start/stop Tx queues
net/mana: start/stop Rx queues
net/mana: receive packets
net/mana: send packets
net/mana: start/stop device
net/mana: report queue stats
net/mana: support Rx interrupts

 MAINTAINERS                       |    6 +
 doc/guides/nics/features/mana.ini |   19 +
 doc/guides/nics/index.rst         |    1 +
 doc/guides/nics/mana.rst          |   73 ++
 drivers/net/mana/gdma.c           |  303 ++++++
 drivers/net/mana/mana.c           | 1502 +++++++++++++++++++++++++++++
 drivers/net/mana/mana.h           |  542 +++++++++++
 drivers/net/mana/meson.build      |   48 +
 drivers/net/mana/mp.c             |  336 +++++++
 drivers/net/mana/mr.c             |  348 +++++++
 drivers/net/mana/rx.c             |  531 ++++++++++
 drivers/net/mana/tx.c             |  416 ++++++++
 drivers/net/mana/version.map      |    3 +
 drivers/net/meson.build           |    1 +
 14 files changed, 4129 insertions(+)
 create mode 100644 doc/guides/nics/features/mana.ini
 create mode 100644 doc/guides/nics/mana.rst
 create mode 100644 drivers/net/mana/gdma.c
 create mode 100644 drivers/net/mana/mana.c
 create mode 100644 drivers/net/mana/mana.h
 create mode 100644 drivers/net/mana/meson.build
 create mode 100644 drivers/net/mana/mp.c
 create mode 100644 drivers/net/mana/mr.c
 create mode 100644 drivers/net/mana/rx.c
 create mode 100644 drivers/net/mana/tx.c
 create mode 100644 drivers/net/mana/version.map
Signature · 1 line
2.17.1
#42 lore raw

PATCH v10 1/18 net/mana: add basic driver with build environment and doc

From: Long Li <[email protected]>

MANA is a PCI device. It uses IB verbs to access hardware through the kernel RDMA layer. This patch introduces build environment and basic device probe functions.

---
Change log:
v2:
Fix typos.
Make the driver build only on x86-64 and Linux.
Remove unused header files.
Change port definition to uint16_t or uint8_t (for IB).
Use getline() in place of fgets() to read and truncate a line. v3:
Add meson build check for required functions from RDMA direct verb header file v4:
Remove extra "\n" in logging code.
Use "r" in place of "rb" in fopen() to read text files.
v7:
Remove RTE_ETH_TX_OFFLOAD_TCP_TSO from offload cap.
v8:
Add clarification on driver args usage to nics guide.
Fix coding sytle on function definitions.
Use different variable names in MANA_MKSTR.
Use MANA_ prefix for all macros.
Use RTE_PMD_REGISTER_PCI in place of rte_pci_register.
Add .vendor_id = 0 to the end of PCI table.
Remove RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS from dev_flags.
v9:
Move unused data fields from the header file to later patches that use them. Add minimum required versions in doc/guides/nics/mana.rst.
Remove .name = "net_mana" from rte_pci_driver.
v10:
Add git repo URL for rdma-core in doc.
Define argument name and use it in RTE_PMD_REGISTER_PARAM_STRING Refactor the code on probing an IB port
Change PCI_VENDOR_ID_MICROSOFT and PCI_DEVICE_ID_MICROSOFT_MANA to #define Remove redundant code for setting RTE_ETH_DEV_INTR_RMV

 MAINTAINERS                       |   6 +
 doc/guides/nics/features/mana.ini |  10 +
 doc/guides/nics/index.rst         |   1 +
 doc/guides/nics/mana.rst          |  73 +++
 drivers/net/mana/mana.c           | 732 ++++++++++++++++++++++++++++++
 drivers/net/mana/mana.h           |  97 ++++
 drivers/net/mana/meson.build      |  44 ++
 drivers/net/mana/mp.c             | 241 ++++++++++
 drivers/net/mana/version.map      |   3 +
 drivers/net/meson.build           |   1 +
 10 files changed, 1208 insertions(+)
 create mode 100644 doc/guides/nics/features/mana.ini
 create mode 100644 doc/guides/nics/mana.rst
 create mode 100644 drivers/net/mana/mana.c
 create mode 100644 drivers/net/mana/mana.h
 create mode 100644 drivers/net/mana/meson.build
 create mode 100644 drivers/net/mana/mp.c
 create mode 100644 drivers/net/mana/version.map
MAINTAINERS +6 -0
index a55b379d73..a66c7cdaeb 100644
@@ -831,6 +831,12 @@ F: buildtools/options-ibverbs-static.sh
 F: doc/guides/nics/mlx5.rst
 F: doc/guides/nics/features/mlx5.ini
 
+Microsoft mana
+M: Long Li <[email protected]>
+F: drivers/net/mana
+F: doc/guides/nics/mana.rst
+F: doc/guides/nics/features/mana.ini
+
 Microsoft vdev_netvsc - EXPERIMENTAL
 M: Matan Azrad <[email protected]>
 F: drivers/net/vdev_netvsc/
doc/guides/nics/features/mana.ini new file +10 -0
new file mode 100644
index 0000000000..b92a27374c
@@ -0,0 +1,10 @@
+;
+; Supported features of the 'mana' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+Multiprocess aware   = Y
+Usage doc            = Y
+x86-64               = Y
doc/guides/nics/index.rst +1 -0
index f80906a97d..32c7544968 100644
@@ -41,6 +41,7 @@ Network Interface Controller Drivers
     intel_vf
     kni
     liquidio
+    mana
     memif
     mlx4
     mlx5
doc/guides/nics/mana.rst new file +73 -0

73 lines not on this page · raw message

drivers/net/mana/mana.c new file +732 -0

732 lines not on this page · raw message

drivers/net/mana/mana.h new file +97 -0

97 lines not on this page · raw message

drivers/net/mana/meson.build new file +44 -0

44 lines not on this page · raw message

drivers/net/mana/mp.c new file +241 -0

241 lines not on this page · raw message

drivers/net/mana/version.map new file +3 -0
new file mode 100644
index 0000000000..78c3585d7c
@@ -0,0 +1,3 @@
+DPDK_23 {
+	local: *;
+};
drivers/net/meson.build +1 -0
index 37919eaf8b..35bfa78dee 100644
@@ -34,6 +34,7 @@ drivers = [
         'ixgbe',
         'kni',
         'liquidio',
+        'mana',
         'memif',
         'mlx4',
         'mlx5',
Signature · 1 line
2.17.1
#43 lore raw

Re: [Patch v10 01/18] net/mana: add basic driver with build environment and doc

Quoted 12 lines · On 10/6/2022 12:21 AM, [email protected] wrote:
doc/guides/nics/mana.rst new file +6 -0
new file mode 100644
index 0000000000..eeca153911
@@ -0,0 +1,73 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright 2022 Microsoft Corporation
+
+MANA poll mode driver library
+=============================
+

doc/guides/nics/mana.rst line 16

Quoted 10 lines
doc/guides/nics/mana.rst new file +10 -0
+The MANA poll mode driver library (**librte_net_mana**) implements support
+for Microsoft Azure Network Adapter VF in SR-IOV context.
+
+Features
+--------
+
+Features of the MANA Ethdev PMD are:
+
+Prerequisites
+-------------

Hi Long,

I guess intention was to build the feature list gradually, by updating list in each patch that adds some feature, but somehow feature list remained empty.

Can you please check what went wrong?

If there is no feature to list maybe we can remove the section.

#44 lore raw

RE: [Patch v10 01/18] net/mana: add basic driver with build environment and doc

Quoted 29 lines

Subject: Re: [Patch v10 01/18] net/mana: add basic driver with build environment and doc

Quoted 11 lines · On 10/6/2022 12:21 AM, [email protected] wrote:
doc/guides/nics/mana.rst new renamed from doc/guides/nics/mana.rst +0 -0

file mode 100644 index 0000000000..eeca153911

doc/guides/nics/mana.rst new file +6 -0
@@ -0,0 +1,73 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright 2022 Microsoft Corporation
+
+MANA poll mode driver library
+=============================
+

doc/guides/nics/mana.rst line 16

Quoted 10 lines
doc/guides/nics/mana.rst new file +10 -0
+The MANA poll mode driver library (**librte_net_mana**) implements
+support for Microsoft Azure Network Adapter VF in SR-IOV context.
+
+Features
+--------
+
+Features of the MANA Ethdev PMD are:
+
+Prerequisites
+-------------

Hi Long,

Quoted 6 lines

I guess intention was to build the feature list gradually, by updating list in each patch that adds some feature, but somehow feature list remained empty.

Can you please check what went wrong?

If there is no feature to list maybe we can remove the section.

Thanks for catching this. The features are defined in doc/guides/nics/features/mana.ini. We don't need to list them here. I suggest we remove this section.

I will send a patch.

Long

#45 lore raw

PATCH v10 2/18 net/mana: device configuration and stop

In reply to [email protected]

From: Long Li <[email protected]>

MANA defines its memory allocation functions to override IB layer default functions to allocate device queues. This patch adds the code for device configuration and stop.

---
v2:
Removed validation for offload settings in mana_dev_configure(). v8:
Fix coding style to function definitions.
v10:
Rebase to latest master branch.

 drivers/net/mana/mana.c | 81 ++++++++++++++++++++++++++++++++++++++++-
 drivers/net/mana/mana.h |  4 ++
 2 files changed, 83 insertions(+), 2 deletions(-)
drivers/net/mana/mana.c +79 -2
index 6a7b8a419d..f5084b4a3b 100644
@@ -42,7 +42,85 @@ static rte_spinlock_t mana_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
 int mana_logtype_driver;
 int mana_logtype_init;
 
+/*
+ * Callback from rdma-core to allocate a buffer for a queue.
+ */
+void *
+mana_alloc_verbs_buf(size_t size, void *data)
+{
+	void *ret;
+	size_t alignment = rte_mem_page_size();
+	int socket = (int)(uintptr_t)data;
+
+	DRV_LOG(DEBUG, "size=%zu socket=%d", size, socket);
+
+	if (alignment == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
+
+	ret = rte_zmalloc_socket("mana_verb_buf", size, alignment, socket);
+	if (!ret && size)
+		rte_errno = ENOMEM;
+	return ret;
+}
+
+void
+mana_free_verbs_buf(void *ptr, void *data __rte_unused)
+{
+	rte_free(ptr);
+}
+
+static int
+mana_dev_configure(struct rte_eth_dev *dev)
+{
+	struct mana_priv *priv = dev->data->dev_private;
+	struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
+
+	if (dev_conf->rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
+		dev_conf->rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
+
+	if (dev->data->nb_rx_queues != dev->data->nb_tx_queues) {
+		DRV_LOG(ERR, "Only support equal number of rx/tx queues");
+		return -EINVAL;
+	}
+
+	if (!rte_is_power_of_2(dev->data->nb_rx_queues)) {
+		DRV_LOG(ERR, "number of TX/RX queues must be power of 2");
+		return -EINVAL;
+	}
+
+	priv->num_queues = dev->data->nb_rx_queues;
+
+	manadv_set_context_attr(priv->ib_ctx, MANADV_CTX_ATTR_BUF_ALLOCATORS,
+				(void *)((uintptr_t)&(struct manadv_ctx_allocators){
+					.alloc = &mana_alloc_verbs_buf,
+					.free = &mana_free_verbs_buf,
+					.data = 0,
+				}));
+
+	return 0;
+}
+
+static int
+mana_dev_close(struct rte_eth_dev *dev)
+{
+	struct mana_priv *priv = dev->data->dev_private;
+	int ret;
+
+	ret = ibv_close_device(priv->ib_ctx);
+	if (ret) {
+		ret = errno;
+		return ret;
+	}
+
+	return 0;
+}
+
 static const struct eth_dev_ops mana_dev_ops = {
+	.dev_configure		= mana_dev_configure,
+	.dev_close		= mana_dev_close,
 };
 
 static const struct eth_dev_ops mana_dev_secondary_ops = {
@@ -655,8 +733,7 @@ mana_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 static int
 mana_dev_uninit(struct rte_eth_dev *dev)
 {
-	RTE_SET_USED(dev);
-	return 0;
+	return mana_dev_close(dev);
 }
 
 /*
drivers/net/mana/mana.h +4 -0
index 291dd83f27..d5f9b2661d 100644
@@ -23,6 +23,7 @@ struct mana_process_priv {
 struct mana_priv {
 	struct rte_eth_dev_data *dev_data;
 	struct mana_process_priv *process_priv;
+	int num_queues;
 
 	/* DPDK port */
 	uint16_t port_id;
@@ -94,4 +95,7 @@ int mana_mp_req_verbs_cmd_fd(struct rte_eth_dev *dev);
 
 void mana_mp_req_on_rxtx(struct rte_eth_dev *dev, enum mana_mp_req_type type);
 
+void *mana_alloc_verbs_buf(size_t size, void *data);
+void mana_free_verbs_buf(void *ptr, void *data __rte_unused);
+
 #endif
Signature · 1 line
2.17.1
#46 lore raw

PATCH v10 3/18 net/mana: report supported ptypes

In reply to [email protected]

From: Long Li <[email protected]>

Report supported protocol types.

---
Change log.
v7: change link_speed to RTE_ETH_SPEED_NUM_100G

 drivers/net/mana/mana.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/net/mana/mana.c +17 -0
index f5084b4a3b..16fcfe0e99 100644
@@ -118,9 +118,26 @@ mana_dev_close(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static const uint32_t *
+mana_supported_ptypes(struct rte_eth_dev *dev __rte_unused)
+{
+	static const uint32_t ptypes[] = {
+		RTE_PTYPE_L2_ETHER,
+		RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
+		RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
+		RTE_PTYPE_L4_FRAG,
+		RTE_PTYPE_L4_TCP,
+		RTE_PTYPE_L4_UDP,
+		RTE_PTYPE_UNKNOWN
+	};
+
+	return ptypes;
+}
+
 static const struct eth_dev_ops mana_dev_ops = {
 	.dev_configure		= mana_dev_configure,
 	.dev_close		= mana_dev_close,
+	.dev_supported_ptypes_get = mana_supported_ptypes,
 };
 
 static const struct eth_dev_ops mana_dev_secondary_ops = {
Signature · 1 line
2.17.1
#47 lore raw

PATCH v10 4/18 net/mana: support link update

In reply to [email protected]

From: Long Li <[email protected]>

The carrier state is managed by the Azure host. MANA runs as a VF and always reports "up".

---
 doc/guides/nics/features/mana.ini |  1 +
 drivers/net/mana/mana.c           | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
index b92a27374c..62554b0a0a 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Link status          = P
 Linux                = Y
 Multiprocess aware   = Y
 Usage doc            = Y
drivers/net/mana/mana.c +18 -0
index 16fcfe0e99..2b1f6fcf1e 100644
@@ -134,10 +134,28 @@ mana_supported_ptypes(struct rte_eth_dev *dev __rte_unused)
 	return ptypes;
 }
 
+static int
+mana_dev_link_update(struct rte_eth_dev *dev,
+		     int wait_to_complete __rte_unused)
+{
+	struct rte_eth_link link;
+
+	/* MANA has no concept of carrier state, always reporting UP */
+	link = (struct rte_eth_link) {
+		.link_duplex = RTE_ETH_LINK_FULL_DUPLEX,
+		.link_autoneg = RTE_ETH_LINK_SPEED_FIXED,
+		.link_speed = RTE_ETH_SPEED_NUM_100G,
+		.link_status = RTE_ETH_LINK_UP,
+	};
+
+	return rte_eth_linkstatus_set(dev, &link);
+}
+
 static const struct eth_dev_ops mana_dev_ops = {
 	.dev_configure		= mana_dev_configure,
 	.dev_close		= mana_dev_close,
 	.dev_supported_ptypes_get = mana_supported_ptypes,
+	.link_update		= mana_dev_link_update,
 };
 
 static const struct eth_dev_ops mana_dev_secondary_ops = {
Signature · 1 line
2.17.1
#48 lore raw

PATCH v10 5/18 net/mana: support device removal interrupts

In reply to [email protected]

From: Long Li <[email protected]>

MANA supports PCI hot plug events. Add this interrupt to DPDK core so its parent PMD can detect device removal during Azure servicing or live migration.

---
Change log:
v8:
fix coding style of function definitions.
v9:
remove unused data fields.

 doc/guides/nics/features/mana.ini |   1 +
 drivers/net/mana/mana.c           | 103 ++++++++++++++++++++++++++++++
 drivers/net/mana/mana.h           |   1 +
 3 files changed, 105 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
index 62554b0a0a..8043e11f99 100644
@@ -7,5 +7,6 @@
 Link status          = P
 Linux                = Y
 Multiprocess aware   = Y
+Removal event        = Y
 Usage doc            = Y
 x86-64               = Y
drivers/net/mana/mana.c +103 -0

127 lines not on this page · raw message

drivers/net/mana/mana.h +1 -0
index d5f9b2661d..f249ef1f66 100644
@@ -35,6 +35,7 @@ struct mana_priv {
 	struct ibv_pd *ib_pd;
 	struct ibv_pd *ib_parent_pd;
 	void *db_page;
+	struct rte_intr_handle *intr_handle;
 	int max_rx_queues;
 	int max_tx_queues;
 	int max_rx_desc;
Signature · 1 line
2.17.1
#49 lore raw

PATCH v10 6/18 net/mana: report device info

In reply to [email protected]

From: Long Li <[email protected]>

Add the function to get device info.

---
Change log:
v8:
use new macro definition start with "MANA_"
fix coding style to function definitions
v9:
move data definitions from earlier patch.
v10:
rebase to latest master branch

 doc/guides/nics/features/mana.ini |  1 +
 drivers/net/mana/mana.c           | 83 +++++++++++++++++++++++++++++++
 drivers/net/mana/mana.h           | 28 +++++++++++
 3 files changed, 112 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
index 8043e11f99..566b3e8770 100644
@@ -8,5 +8,6 @@ Link status          = P
 Linux                = Y
 Multiprocess aware   = Y
 Removal event        = Y
+Speed capabilities   = P
 Usage doc            = Y
 x86-64               = Y
drivers/net/mana/mana.c +83 -0

100 lines not on this page · raw message

drivers/net/mana/mana.h +28 -0
index f249ef1f66..a3165616ce 100644
@@ -16,6 +16,34 @@ struct mana_shared_data {
 	unsigned int secondary_cnt;
 };
 
+#define MIN_RX_BUF_SIZE	1024
+#define MAX_FRAME_SIZE	RTE_ETHER_MAX_LEN
+#define MANA_MAX_MAC_ADDR 1
+
+#define MANA_DEV_RX_OFFLOAD_SUPPORT ( \
+		RTE_ETH_RX_OFFLOAD_CHECKSUM | \
+		RTE_ETH_RX_OFFLOAD_RSS_HASH)
+
+#define MANA_DEV_TX_OFFLOAD_SUPPORT ( \
+		RTE_ETH_TX_OFFLOAD_MULTI_SEGS | \
+		RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | \
+		RTE_ETH_TX_OFFLOAD_TCP_CKSUM | \
+		RTE_ETH_TX_OFFLOAD_UDP_CKSUM)
+
+#define INDIRECTION_TABLE_NUM_ELEMENTS 64
+#define TOEPLITZ_HASH_KEY_SIZE_IN_BYTES 40
+#define MANA_ETH_RSS_SUPPORT ( \
+	RTE_ETH_RSS_IPV4 |	     \
+	RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
+	RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
+	RTE_ETH_RSS_IPV6 |	     \
+	RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
+	RTE_ETH_RSS_NONFRAG_IPV6_UDP)
+
+#define MIN_BUFFERS_PER_QUEUE		64
+#define MAX_RECEIVE_BUFFERS_PER_QUEUE	256
+#define MAX_SEND_BUFFERS_PER_QUEUE	256
+
 struct mana_process_priv {
 	void *db_page;
 };
Signature · 1 line
2.17.1
#50 lore raw

PATCH v10 7/18 net/mana: configure RSS

In reply to [email protected]

From: Long Li <[email protected]>

Currently this PMD supports RSS configuration when the device is stopped. Configuring RSS in running state will be supported in the future.

---
change log:
v8:
fix coding sytle to function definitions
v10:
remove accidentally introduced change from v9

 doc/guides/nics/features/mana.ini |  1 +
 drivers/net/mana/mana.c           | 63 +++++++++++++++++++++++++++++++
 drivers/net/mana/mana.h           |  1 +
 3 files changed, 65 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
index 566b3e8770..a59c21cc10 100644
@@ -8,6 +8,7 @@ Link status          = P
 Linux                = Y
 Multiprocess aware   = Y
 Removal event        = Y
+RSS hash             = Y
 Speed capabilities   = P
 Usage doc            = Y
 x86-64               = Y
drivers/net/mana/mana.c +63 -0

75 lines not on this page · raw message

drivers/net/mana/mana.h +1 -0
index a3165616ce..e67719e11d 100644
@@ -63,6 +63,7 @@ struct mana_priv {
 	struct ibv_pd *ib_pd;
 	struct ibv_pd *ib_parent_pd;
 	void *db_page;
+	struct rte_eth_rss_conf rss_conf;
 	struct rte_intr_handle *intr_handle;
 	int max_rx_queues;
 	int max_tx_queues;
Signature · 1 line
2.17.1
#51 lore raw

PATCH v10 8/18 net/mana: configure Rx queues

In reply to [email protected]

From: Long Li <[email protected]>

Rx hardware queue is allocated when starting the queue. This function is for queue configuration pre starting.

---
Change log:
v8:
fix coding style to function definitions
v9:
move data defintions from earlier patch.

 drivers/net/mana/mana.c | 71 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/mana/mana.h | 21 ++++++++++++
 2 files changed, 92 insertions(+)
drivers/net/mana/mana.c +71 -0
index 2bfda50f37..d19be6f852 100644
@@ -205,6 +205,17 @@ mana_dev_info_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static void
+mana_dev_rx_queue_info(struct rte_eth_dev *dev, uint16_t queue_id,
+		       struct rte_eth_rxq_info *qinfo)
+{
+	struct mana_rxq *rxq = dev->data->rx_queues[queue_id];
+
+	qinfo->mp = rxq->mp;
+	qinfo->nb_desc = rxq->num_desc;
+	qinfo->conf.offloads = dev->data->dev_conf.rxmode.offloads;
+}
+
 static const uint32_t *
 mana_supported_ptypes(struct rte_eth_dev *dev __rte_unused)
 {
@@ -282,6 +293,63 @@ mana_rss_hash_conf_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+mana_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
+			uint16_t nb_desc, unsigned int socket_id,
+			const struct rte_eth_rxconf *rx_conf __rte_unused,
+			struct rte_mempool *mp)
+{
+	struct mana_priv *priv = dev->data->dev_private;
+	struct mana_rxq *rxq;
+	int ret;
+
+	rxq = rte_zmalloc_socket("mana_rxq", sizeof(*rxq), 0, socket_id);
+	if (!rxq) {
+		DRV_LOG(ERR, "failed to allocate rxq");
+		return -ENOMEM;
+	}
+
+	DRV_LOG(DEBUG, "idx %u nb_desc %u socket %u",
+		queue_idx, nb_desc, socket_id);
+
+	rxq->socket = socket_id;
+
+	rxq->desc_ring = rte_zmalloc_socket("mana_rx_mbuf_ring",
+					    sizeof(struct mana_rxq_desc) *
+						nb_desc,
+					    RTE_CACHE_LINE_SIZE, socket_id);
+
+	if (!rxq->desc_ring) {
+		DRV_LOG(ERR, "failed to allocate rxq desc_ring");
+		ret = -ENOMEM;
+		goto fail;
+	}
+
+	rxq->desc_ring_head = 0;
+	rxq->desc_ring_tail = 0;
+
+	rxq->priv = priv;
+	rxq->num_desc = nb_desc;
+	rxq->mp = mp;
+	dev->data->rx_queues[queue_idx] = rxq;
+
+	return 0;
+
+fail:
+	rte_free(rxq->desc_ring);
+	rte_free(rxq);
+	return ret;
+}
+
+static void
+mana_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
+{
+	struct mana_rxq *rxq = dev->data->rx_queues[qid];
+
+	rte_free(rxq->desc_ring);
+	rte_free(rxq);
+}
+
 static int
 mana_dev_link_update(struct rte_eth_dev *dev,
 		     int wait_to_complete __rte_unused)
@@ -303,9 +371,12 @@ static const struct eth_dev_ops mana_dev_ops = {
 	.dev_configure		= mana_dev_configure,
 	.dev_close		= mana_dev_close,
 	.dev_infos_get		= mana_dev_info_get,
+	.rxq_info_get		= mana_dev_rx_queue_info,
 	.dev_supported_ptypes_get = mana_supported_ptypes,
 	.rss_hash_update	= mana_rss_hash_update,
 	.rss_hash_conf_get	= mana_rss_hash_conf_get,
+	.rx_queue_setup		= mana_dev_rx_queue_setup,
+	.rx_queue_release	= mana_dev_rx_queue_release,
 	.link_update		= mana_dev_link_update,
 };
 
drivers/net/mana/mana.h +21 -0
index e67719e11d..4cd225fe6e 100644
@@ -75,6 +75,27 @@ struct mana_priv {
 	uint64_t max_mr_size;
 };
 
+struct mana_rxq_desc {
+	struct rte_mbuf *pkt;
+	uint32_t wqe_size_in_bu;
+};
+
+struct mana_rxq {
+	struct mana_priv *priv;
+	uint32_t num_desc;
+	struct rte_mempool *mp;
+
+	/* For storing pending requests */
+	struct mana_rxq_desc *desc_ring;
+
+	/* desc_ring_head is where we put pending requests to ring,
+	 * completion pull off desc_ring_tail
+	 */
+	uint32_t desc_ring_head, desc_ring_tail;
+
+	unsigned int socket;
+};
+
 extern int mana_logtype_driver;
 extern int mana_logtype_init;
 
Signature · 1 line
2.17.1
#52 lore raw

PATCH v10 9/18 net/mana: configure Tx queues

In reply to [email protected]

From: Long Li <[email protected]>

Tx hardware queue is allocated when starting the queue, this is for pre configuration.

---
change log:
v8:
fix coding style to function definitions
v9:
move data definitions from earlier patch.

 drivers/net/mana/mana.c | 67 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/mana/mana.h | 20 ++++++++++++
 2 files changed, 87 insertions(+)
drivers/net/mana/mana.c +67 -0
index d19be6f852..8f6996c202 100644
@@ -205,6 +205,16 @@ mana_dev_info_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static void
+mana_dev_tx_queue_info(struct rte_eth_dev *dev, uint16_t queue_id,
+		       struct rte_eth_txq_info *qinfo)
+{
+	struct mana_txq *txq = dev->data->tx_queues[queue_id];
+
+	qinfo->conf.offloads = dev->data->dev_conf.txmode.offloads;
+	qinfo->nb_desc = txq->num_desc;
+}
+
 static void
 mana_dev_rx_queue_info(struct rte_eth_dev *dev, uint16_t queue_id,
 		       struct rte_eth_rxq_info *qinfo)
@@ -293,6 +303,60 @@ mana_rss_hash_conf_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+mana_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
+			uint16_t nb_desc, unsigned int socket_id,
+			const struct rte_eth_txconf *tx_conf __rte_unused)
+
+{
+	struct mana_priv *priv = dev->data->dev_private;
+	struct mana_txq *txq;
+	int ret;
+
+	txq = rte_zmalloc_socket("mana_txq", sizeof(*txq), 0, socket_id);
+	if (!txq) {
+		DRV_LOG(ERR, "failed to allocate txq");
+		return -ENOMEM;
+	}
+
+	txq->socket = socket_id;
+
+	txq->desc_ring = rte_malloc_socket("mana_tx_desc_ring",
+					   sizeof(struct mana_txq_desc) *
+						nb_desc,
+					   RTE_CACHE_LINE_SIZE, socket_id);
+	if (!txq->desc_ring) {
+		DRV_LOG(ERR, "failed to allocate txq desc_ring");
+		ret = -ENOMEM;
+		goto fail;
+	}
+
+	DRV_LOG(DEBUG, "idx %u nb_desc %u socket %u txq->desc_ring %p",
+		queue_idx, nb_desc, socket_id, txq->desc_ring);
+
+	txq->desc_ring_head = 0;
+	txq->desc_ring_tail = 0;
+	txq->priv = priv;
+	txq->num_desc = nb_desc;
+	dev->data->tx_queues[queue_idx] = txq;
+
+	return 0;
+
+fail:
+	rte_free(txq->desc_ring);
+	rte_free(txq);
+	return ret;
+}
+
+static void
+mana_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
+{
+	struct mana_txq *txq = dev->data->tx_queues[qid];
+
+	rte_free(txq->desc_ring);
+	rte_free(txq);
+}
+
 static int
 mana_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
@@ -371,10 +435,13 @@ static const struct eth_dev_ops mana_dev_ops = {
 	.dev_configure		= mana_dev_configure,
 	.dev_close		= mana_dev_close,
 	.dev_infos_get		= mana_dev_info_get,
+	.txq_info_get		= mana_dev_tx_queue_info,
 	.rxq_info_get		= mana_dev_rx_queue_info,
 	.dev_supported_ptypes_get = mana_supported_ptypes,
 	.rss_hash_update	= mana_rss_hash_update,
 	.rss_hash_conf_get	= mana_rss_hash_conf_get,
+	.tx_queue_setup		= mana_dev_tx_queue_setup,
+	.tx_queue_release	= mana_dev_tx_queue_release,
 	.rx_queue_setup		= mana_dev_rx_queue_setup,
 	.rx_queue_release	= mana_dev_rx_queue_release,
 	.link_update		= mana_dev_link_update,
drivers/net/mana/mana.h +20 -0
index 4cd225fe6e..d10c0830fe 100644
@@ -75,11 +75,31 @@ struct mana_priv {
 	uint64_t max_mr_size;
 };
 
+struct mana_txq_desc {
+	struct rte_mbuf *pkt;
+	uint32_t wqe_size_in_bu;
+};
+
 struct mana_rxq_desc {
 	struct rte_mbuf *pkt;
 	uint32_t wqe_size_in_bu;
 };
 
+struct mana_txq {
+	struct mana_priv *priv;
+	uint32_t num_desc;
+
+	/* For storing pending requests */
+	struct mana_txq_desc *desc_ring;
+
+	/* desc_ring_head is where we put pending requests to ring,
+	 * completion pull off desc_ring_tail
+	 */
+	uint32_t desc_ring_head, desc_ring_tail;
+
+	unsigned int socket;
+};
+
 struct mana_rxq {
 	struct mana_priv *priv;
 	uint32_t num_desc;
Signature · 1 line
2.17.1
#53 lore raw

PATCH v10 10/18 net/mana: implement memory registration

In reply to [email protected]

From: Long Li <[email protected]>

MANA hardware has iommu built-in, that provides hardware safe access to user memory through memory registration. Since memory registration is an expensive operation, this patch implements a two level memory registration cache mechanisum for each queue and for each port.

---
Change log:
v2:
Change all header file functions to start with mana_. Use spinlock in place of rwlock to memory cache access. Remove unused header files.
v4:
Remove extra "\n" in logging function.
v8:
Fix Coding style to function definitions.
v9:
Move data definitions from earlier patch.

 drivers/net/mana/mana.c      |  20 ++
 drivers/net/mana/mana.h      |  42 +++++
 drivers/net/mana/meson.build |   1 +
 drivers/net/mana/mp.c        |  92 +++++++++
 drivers/net/mana/mr.c        | 348 +++++++++++++++++++++++++++++++++++
 5 files changed, 503 insertions(+)
 create mode 100644 drivers/net/mana/mr.c
drivers/net/mana/mana.c +20 -0
index 8f6996c202..1076f6871a 100644
@@ -111,6 +111,8 @@ mana_dev_close(struct rte_eth_dev *dev)
 	struct mana_priv *priv = dev->data->dev_private;
 	int ret;
 
+	mana_remove_all_mr(priv);
+
 	ret = mana_intr_uninstall(priv);
 	if (ret)
 		return ret;
@@ -331,6 +333,13 @@ mana_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 		goto fail;
 	}
 
+	ret = mana_mr_btree_init(&txq->mr_btree,
+				 MANA_MR_BTREE_PER_QUEUE_N, socket_id);
+	if (ret) {
+		DRV_LOG(ERR, "Failed to init TXQ MR btree");
+		goto fail;
+	}
+
 	DRV_LOG(DEBUG, "idx %u nb_desc %u socket %u txq->desc_ring %p",
 		queue_idx, nb_desc, socket_id, txq->desc_ring);
 
@@ -353,6 +362,8 @@ mana_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 {
 	struct mana_txq *txq = dev->data->tx_queues[qid];
 
+	mana_mr_btree_free(&txq->mr_btree);
+
 	rte_free(txq->desc_ring);
 	rte_free(txq);
 }
@@ -392,6 +403,13 @@ mana_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	rxq->desc_ring_head = 0;
 	rxq->desc_ring_tail = 0;
 
+	ret = mana_mr_btree_init(&rxq->mr_btree,
+				 MANA_MR_BTREE_PER_QUEUE_N, socket_id);
+	if (ret) {
+		DRV_LOG(ERR, "Failed to init RXQ MR btree");
+		goto fail;
+	}
+
 	rxq->priv = priv;
 	rxq->num_desc = nb_desc;
 	rxq->mp = mp;
@@ -410,6 +428,8 @@ mana_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 {
 	struct mana_rxq *rxq = dev->data->rx_queues[qid];
 
+	mana_mr_btree_free(&rxq->mr_btree);
+
 	rte_free(rxq->desc_ring);
 	rte_free(rxq);
 }
drivers/net/mana/mana.h +42 -0

84 lines not on this page · raw message

drivers/net/mana/meson.build +1 -0
index ae6beda5e0..c4a19ad745 100644
@@ -12,6 +12,7 @@ deps += ['pci', 'bus_pci', 'net', 'eal', 'kvargs']
 sources += files(
         'mana.c',
         'mp.c',
+        'mr.c',
 )
 
 libnames = ['ibverbs', 'mana' ]
drivers/net/mana/mp.c +92 -0

110 lines not on this page · raw message

drivers/net/mana/mr.c new file +348 -0

348 lines not on this page · raw message

Signature · 1 line
2.17.1
#54 lore raw

PATCH v10 11/18 net/mana: implement the hardware layer operations

In reply to [email protected]

From: Long Li <[email protected]>

The hardware layer of MANA understands the device queue and doorbell formats. Those functions are implemented for use by packet RX/TX code.

---
Change log:
v2:
Remove unused header files.
Rename a camel case.
v5:
Use RTE_BIT32() instead of defining a new BIT()
v6:
add rte_rmb() after reading owner bits
v8:
fix coding style to function definitions.
use capital letters for all enum names
v9:
Add back RTE_BIT32() in v5 (rebase accident)
Move data definitoins from earlier patch.
v10:
Use enum for DOORBELL_OFFSET_XXX

 drivers/net/mana/gdma.c      | 303 +++++++++++++++++++++++++++++++++++
 drivers/net/mana/mana.h      | 191 ++++++++++++++++++++++
 drivers/net/mana/meson.build |   1 +
 3 files changed, 495 insertions(+)
 create mode 100644 drivers/net/mana/gdma.c
drivers/net/mana/gdma.c new file +303 -0
new file mode 100644
index 0000000000..370324208a
@@ -0,0 +1,303 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2022 Microsoft Corporation
+ */
+
+#include <ethdev_driver.h>
+#include <rte_io.h>
+
+#include "mana.h"
+
+uint8_t *
+gdma_get_wqe_pointer(struct mana_gdma_queue *queue)
+{
+	uint32_t offset_in_bytes =
+		(queue->head * GDMA_WQE_ALIGNMENT_UNIT_SIZE) &
+		(queue->size - 1);
+
+	DRV_LOG(DEBUG, "txq sq_head %u sq_size %u offset_in_bytes %u",
+		queue->head, queue->size, offset_in_bytes);
+
+	if (offset_in_bytes + GDMA_WQE_ALIGNMENT_UNIT_SIZE > queue->size)
+		DRV_LOG(ERR, "fatal error: offset_in_bytes %u too big",
+			offset_in_bytes);
+
+	return ((uint8_t *)queue->buffer) + offset_in_bytes;
+}
+
+static uint32_t
+write_dma_client_oob(uint8_t *work_queue_buffer_pointer,
+		     const struct gdma_work_request *work_request,
+		     uint32_t client_oob_size)
+{
+	uint8_t *p = work_queue_buffer_pointer;
+
+	struct gdma_wqe_dma_oob *header = (struct gdma_wqe_dma_oob *)p;
+
+	memset(header, 0, sizeof(struct gdma_wqe_dma_oob));
+	header->num_sgl_entries = work_request->num_sgl_elements;
+	header->inline_client_oob_size_in_dwords =
+		client_oob_size / sizeof(uint32_t);
+	header->client_data_unit = work_request->client_data_unit;
+
+	DRV_LOG(DEBUG, "queue buf %p sgl %u oob_h %u du %u oob_buf %p oob_b %u",
+		work_queue_buffer_pointer, header->num_sgl_entries,
+		header->inline_client_oob_size_in_dwords,
+		header->client_data_unit, work_request->inline_oob_data,
+		work_request->inline_oob_size_in_bytes);
+
+	p += sizeof(struct gdma_wqe_dma_oob);
+	if (work_request->inline_oob_data &&
+	    work_request->inline_oob_size_in_bytes > 0) {
+		memcpy(p, work_request->inline_oob_data,
+		       work_request->inline_oob_size_in_bytes);
+		if (client_oob_size > work_request->inline_oob_size_in_bytes)
+			memset(p + work_request->inline_oob_size_in_bytes, 0,
+			       client_oob_size -
+			       work_request->inline_oob_size_in_bytes);
+	}
+
+	return sizeof(struct gdma_wqe_dma_oob) + client_oob_size;
+}
+
+static uint32_t
+write_scatter_gather_list(uint8_t *work_queue_head_pointer,
+			  uint8_t *work_queue_end_pointer,
+			  uint8_t *work_queue_cur_pointer,
+			  struct gdma_work_request *work_request)
+{
+	struct gdma_sgl_element *sge_list;
+	struct gdma_sgl_element dummy_sgl[1];
+	uint8_t *address;
+	uint32_t size;
+	uint32_t num_sge;
+	uint32_t size_to_queue_end;
+	uint32_t sge_list_size;
+
+	DRV_LOG(DEBUG, "work_queue_cur_pointer %p work_request->flags %x",
+		work_queue_cur_pointer, work_request->flags);
+
+	num_sge = work_request->num_sgl_elements;
+	sge_list = work_request->sgl;
+	size_to_queue_end = (uint32_t)(work_queue_end_pointer -
+				       work_queue_cur_pointer);
+
+	if (num_sge == 0) {
+		/* Per spec, the case of an empty SGL should be handled as
+		 * follows to avoid corrupted WQE errors:
+		 * Write one dummy SGL entry
+		 * Set the address to 1, leave the rest as 0
+		 */
+		dummy_sgl[num_sge].address = 1;
+		dummy_sgl[num_sge].size = 0;
+		dummy_sgl[num_sge].memory_key = 0;
+		num_sge++;
+		sge_list = dummy_sgl;
+	}
+
+	sge_list_size = 0;
+	{
+		address = (uint8_t *)sge_list;
+		size = sizeof(struct gdma_sgl_element) * num_sge;
+		if (size_to_queue_end < size) {
+			memcpy(work_queue_cur_pointer, address,
+			       size_to_queue_end);
+			work_queue_cur_pointer = work_queue_head_pointer;
+			address += size_to_queue_end;
+			size -= size_to_queue_end;
+		}
+
+		memcpy(work_queue_cur_pointer, address, size);
+		sge_list_size = size;
+	}
+
+	DRV_LOG(DEBUG, "sge %u address 0x%" PRIx64 " size %u key %u list_s %u",
+		num_sge, sge_list->address, sge_list->size,
+		sge_list->memory_key, sge_list_size);
+
+	return sge_list_size;
+}
+
+/*
+ * Post a work request to queue.
+ */
+int
+gdma_post_work_request(struct mana_gdma_queue *queue,
+		       struct gdma_work_request *work_req,
+		       struct gdma_posted_wqe_info *wqe_info)
+{
+	uint32_t client_oob_size =
+		work_req->inline_oob_size_in_bytes >
+				INLINE_OOB_SMALL_SIZE_IN_BYTES ?
+			INLINE_OOB_LARGE_SIZE_IN_BYTES :
+			INLINE_OOB_SMALL_SIZE_IN_BYTES;
+
+	uint32_t sgl_data_size = sizeof(struct gdma_sgl_element) *
+			RTE_MAX((uint32_t)1, work_req->num_sgl_elements);
+	uint32_t wqe_size =
+		RTE_ALIGN(sizeof(struct gdma_wqe_dma_oob) +
+				client_oob_size + sgl_data_size,
+			  GDMA_WQE_ALIGNMENT_UNIT_SIZE);
+	uint8_t *wq_buffer_pointer;
+	uint32_t queue_free_units = queue->count - (queue->head - queue->tail);
+
+	if (wqe_size / GDMA_WQE_ALIGNMENT_UNIT_SIZE > queue_free_units) {
+		DRV_LOG(DEBUG, "WQE size %u queue count %u head %u tail %u",
+			wqe_size, queue->count, queue->head, queue->tail);
+		return -EBUSY;
+	}
+
+	DRV_LOG(DEBUG, "client_oob_size %u sgl_data_size %u wqe_size %u",
+		client_oob_size, sgl_data_size, wqe_size);
+
+	if (wqe_info) {
+		wqe_info->wqe_index =
+			((queue->head * GDMA_WQE_ALIGNMENT_UNIT_SIZE) &
+			 (queue->size - 1)) / GDMA_WQE_ALIGNMENT_UNIT_SIZE;
+		wqe_info->unmasked_queue_offset = queue->head;
+		wqe_info->wqe_size_in_bu =
+			wqe_size / GDMA_WQE_ALIGNMENT_UNIT_SIZE;
+	}
+
+	wq_buffer_pointer = gdma_get_wqe_pointer(queue);
+	wq_buffer_pointer += write_dma_client_oob(wq_buffer_pointer, work_req,
+						  client_oob_size);
+	if (wq_buffer_pointer >= ((uint8_t *)queue->buffer) + queue->size)
+		wq_buffer_pointer -= queue->size;
+
+	write_scatter_gather_list((uint8_t *)queue->buffer,
+				  (uint8_t *)queue->buffer + queue->size,
+				  wq_buffer_pointer, work_req);
+
+	queue->head += wqe_size / GDMA_WQE_ALIGNMENT_UNIT_SIZE;
+
+	return 0;
+}
+
+union gdma_doorbell_entry {
+	uint64_t     as_uint64;
+
+	struct {
+		uint64_t id	  : 24;
+		uint64_t reserved    : 8;
+		uint64_t tail_ptr    : 31;
+		uint64_t arm	 : 1;
+	} cq;
+
+	struct {
+		uint64_t id	  : 24;
+		uint64_t wqe_cnt     : 8;
+		uint64_t tail_ptr    : 32;
+	} rq;
+
+	struct {
+		uint64_t id	  : 24;
+		uint64_t reserved    : 8;
+		uint64_t tail_ptr    : 32;
+	} sq;
+
+	struct {
+		uint64_t id	  : 16;
+		uint64_t reserved    : 16;
+		uint64_t tail_ptr    : 31;
+		uint64_t arm	 : 1;
+	} eq;
+}; /* HW DATA */
+
+enum {
+	DOORBELL_OFFSET_SQ = 0x0,
+	DOORBELL_OFFSET_RQ = 0x400,
+	DOORBELL_OFFSET_CQ = 0x800,
+	DOORBELL_OFFSET_EQ = 0xFF8,
+};
+
+/*
+ * Write to hardware doorbell to notify new activity.
+ */
+int
+mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
+		   uint32_t queue_id, uint32_t tail)
+{
+	uint8_t *addr = db_page;
+	union gdma_doorbell_entry e = {};
+
+	switch (queue_type) {
+	case GDMA_QUEUE_SEND:
+		e.sq.id = queue_id;
+		e.sq.tail_ptr = tail;
+		addr += DOORBELL_OFFSET_SQ;
+		break;
+
+	case GDMA_QUEUE_RECEIVE:
+		e.rq.id = queue_id;
+		e.rq.tail_ptr = tail;
+		e.rq.wqe_cnt = 1;
+		addr += DOORBELL_OFFSET_RQ;
+		break;
+
+	case GDMA_QUEUE_COMPLETION:
+		e.cq.id = queue_id;
+		e.cq.tail_ptr = tail;
+		e.cq.arm = 1;
+		addr += DOORBELL_OFFSET_CQ;
+		break;
+
+	default:
+		DRV_LOG(ERR, "Unsupported queue type %d", queue_type);
+		return -1;
+	}
+
+	/* Ensure all writes are done before ringing doorbell */
+	rte_wmb();
+
+	DRV_LOG(DEBUG, "db_page %p addr %p queue_id %u type %u tail %u",
+		db_page, addr, queue_id, queue_type, tail);
+
+	rte_write64(e.as_uint64, addr);
+	return 0;
+}
+
+/*
+ * Poll completion queue for completions.
+ */
+int
+gdma_poll_completion_queue(struct mana_gdma_queue *cq, struct gdma_comp *comp)
+{
+	struct gdma_hardware_completion_entry *cqe;
+	uint32_t head = cq->head % cq->count;
+	uint32_t new_owner_bits, old_owner_bits;
+	uint32_t cqe_owner_bits;
+	struct gdma_hardware_completion_entry *buffer = cq->buffer;
+
+	cqe = &buffer[head];
+	new_owner_bits = (cq->head / cq->count) & COMPLETION_QUEUE_OWNER_MASK;
+	old_owner_bits = (cq->head / cq->count - 1) &
+				COMPLETION_QUEUE_OWNER_MASK;
+	cqe_owner_bits = cqe->owner_bits;
+
+	DRV_LOG(DEBUG, "comp cqe bits 0x%x owner bits 0x%x",
+		cqe_owner_bits, old_owner_bits);
+
+	if (cqe_owner_bits == old_owner_bits)
+		return 0; /* No new entry */
+
+	if (cqe_owner_bits != new_owner_bits) {
+		DRV_LOG(ERR, "CQ overflowed, ID %u cqe 0x%x new 0x%x",
+			cq->id, cqe_owner_bits, new_owner_bits);
+		return -1;
+	}
+
+	/* Ensure checking owner bits happens before reading from CQE */
+	rte_rmb();
+
+	comp->work_queue_number = cqe->wq_num;
+	comp->send_work_queue = cqe->is_sq;
+
+	memcpy(comp->completion_data, cqe->dma_client_data, GDMA_COMP_DATA_SIZE);
+
+	cq->head++;
+
+	DRV_LOG(DEBUG, "comp new 0x%x old 0x%x cqe 0x%x wq %u sq %u head %u",
+		new_owner_bits, old_owner_bits, cqe_owner_bits,
+		comp->work_queue_number, comp->send_work_queue, cq->head);
+	return 1;
+}
drivers/net/mana/mana.h +191 -0

215 lines not on this page · raw message

drivers/net/mana/meson.build +1 -0
index c4a19ad745..dea8b97afb 100644
@@ -10,6 +10,7 @@ endif
 deps += ['pci', 'bus_pci', 'net', 'eal', 'kvargs']
 
 sources += files(
+        'gdma.c',
         'mana.c',
         'mp.c',
         'mr.c',
Signature · 1 line
2.17.1
#55 lore raw

PATCH v10 12/18 net/mana: start/stop Tx queues

In reply to [email protected]

From: Long Li <[email protected]>

MANA allocate device queues through the IB layer when starting Tx queues. When device is stopped all the queues are unmapped and freed.

---
Change log:
v2:
Add prefix mana_ to all function names.
Remove unused header files.
v8:
fix coding style to function definitions.
v9:
move some data definitions from earlier patch.

 doc/guides/nics/features/mana.ini |   1 +
 drivers/net/mana/mana.h           |  11 ++
 drivers/net/mana/meson.build      |   1 +
 drivers/net/mana/tx.c             | 166 ++++++++++++++++++++++++++++++
 4 files changed, 179 insertions(+)
 create mode 100644 drivers/net/mana/tx.c
doc/guides/nics/features/mana.ini +1 -0
index a59c21cc10..821443b292 100644
@@ -7,6 +7,7 @@
 Link status          = P
 Linux                = Y
 Multiprocess aware   = Y
+Queue start/stop     = Y
 Removal event        = Y
 RSS hash             = Y
 Speed capabilities   = P
drivers/net/mana/mana.h +11 -0
index 09e2fc3e61..b6e51e7fdd 100644
@@ -288,6 +288,13 @@ struct mana_gdma_queue {
 struct mana_txq {
 	struct mana_priv *priv;
 	uint32_t num_desc;
+	struct ibv_cq *cq;
+	struct ibv_qp *qp;
+
+	struct mana_gdma_queue gdma_sq;
+	struct mana_gdma_queue gdma_cq;
+
+	uint32_t tx_vp_offset;
 
 	/* For storing pending requests */
 	struct mana_txq_desc *desc_ring;
@@ -349,6 +356,10 @@ uint16_t mana_tx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,
 int gdma_poll_completion_queue(struct mana_gdma_queue *cq,
 			       struct gdma_comp *comp);
 
+int mana_start_tx_queues(struct rte_eth_dev *dev);
+
+int mana_stop_tx_queues(struct rte_eth_dev *dev);
+
 struct mana_mr_cache *mana_find_pmd_mr(struct mana_mr_btree *local_tree,
 				       struct mana_priv *priv,
 				       struct rte_mbuf *mbuf);
drivers/net/mana/meson.build +1 -0
index dea8b97afb..2ffb76a36a 100644
@@ -14,6 +14,7 @@ sources += files(
         'mana.c',
         'mp.c',
         'mr.c',
+        'tx.c',
 )
 
 libnames = ['ibverbs', 'mana' ]
drivers/net/mana/tx.c new file +166 -0

166 lines not on this page · raw message

Signature · 1 line
2.17.1
#56 lore raw

PATCH v10 13/18 net/mana: start/stop Rx queues

In reply to [email protected]

From: Long Li <[email protected]>

MANA allocates device queues through the IB layer when starting Rx queues. When device is stopped all the queues are unmapped and freed.

---
Change log:
v2:
Add prefix mana_ to all function names.
Remove unused header files.
v4:
Move defition "uint32_t i" from inside "for ()" to outside v8:
Fix coding style to function definitions.
v9:
Move data definitions from earlier patch.
v10:
Rebase to latest master branch

 drivers/net/mana/mana.h      |  18 ++
 drivers/net/mana/meson.build |   1 +
 drivers/net/mana/rx.c        | 354 +++++++++++++++++++++++++++++++++++
 3 files changed, 373 insertions(+)
 create mode 100644 drivers/net/mana/rx.c
drivers/net/mana/mana.h +18 -0
index b6e51e7fdd..01a3177a19 100644
@@ -249,6 +249,8 @@ struct mana_priv {
 	struct ibv_context *ib_ctx;
 	struct ibv_pd *ib_pd;
 	struct ibv_pd *ib_parent_pd;
+	struct ibv_rwq_ind_table *ind_table;
+	struct ibv_qp *rwq_qp;
 	void *db_page;
 	struct rte_eth_rss_conf rss_conf;
 	struct rte_intr_handle *intr_handle;
@@ -274,6 +276,13 @@ struct mana_rxq_desc {
 	uint32_t wqe_size_in_bu;
 };
 
+struct mana_stats {
+	uint64_t packets;
+	uint64_t bytes;
+	uint64_t errors;
+	uint64_t nombuf;
+};
+
 struct mana_gdma_queue {
 	void *buffer;
 	uint32_t count;	/* in entries */
@@ -312,6 +321,8 @@ struct mana_rxq {
 	struct mana_priv *priv;
 	uint32_t num_desc;
 	struct rte_mempool *mp;
+	struct ibv_cq *cq;
+	struct ibv_wq *wq;
 
 	/* For storing pending requests */
 	struct mana_rxq_desc *desc_ring;
@@ -321,6 +332,10 @@ struct mana_rxq {
 	 */
 	uint32_t desc_ring_head, desc_ring_tail;
 
+	struct mana_gdma_queue gdma_rq;
+	struct mana_gdma_queue gdma_cq;
+
+	struct mana_stats stats;
 	struct mana_mr_btree mr_btree;
 
 	unsigned int socket;
@@ -341,6 +356,7 @@ extern int mana_logtype_init;
 
 int mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
 		       uint32_t queue_id, uint32_t tail);
+int mana_rq_ring_doorbell(struct mana_rxq *rxq);
 
 int gdma_post_work_request(struct mana_gdma_queue *queue,
 			   struct gdma_work_request *work_req,
@@ -356,8 +372,10 @@ uint16_t mana_tx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,
 int gdma_poll_completion_queue(struct mana_gdma_queue *cq,
 			       struct gdma_comp *comp);
 
+int mana_start_rx_queues(struct rte_eth_dev *dev);
 int mana_start_tx_queues(struct rte_eth_dev *dev);
 
+int mana_stop_rx_queues(struct rte_eth_dev *dev);
 int mana_stop_tx_queues(struct rte_eth_dev *dev);
 
 struct mana_mr_cache *mana_find_pmd_mr(struct mana_mr_btree *local_tree,
drivers/net/mana/meson.build +1 -0
index 2ffb76a36a..bdf526e846 100644
@@ -14,6 +14,7 @@ sources += files(
         'mana.c',
         'mp.c',
         'mr.c',
+        'rx.c',
         'tx.c',
 )
 
drivers/net/mana/rx.c new file +354 -0

354 lines not on this page · raw message

Signature · 1 line
2.17.1
#57 lore raw

PATCH v10 14/18 net/mana: receive packets

In reply to [email protected]

From: Long Li <[email protected]>

With all the RX queues created, MANA can use those queues to receive packets.

---
Change log:
v2:
Add mana_ to all function names.
Rename a camel case.
v8:
Fix coding style to function definitions.
v10:
Rearrange the order in doc/guides/nics/features/mana.ini

 doc/guides/nics/features/mana.ini |   2 +
 drivers/net/mana/mana.h           |  37 +++++++++++
 drivers/net/mana/mp.c             |   2 +
 drivers/net/mana/rx.c             | 105 ++++++++++++++++++++++++++++++
 4 files changed, 146 insertions(+)
doc/guides/nics/features/mana.ini +2 -0
index 821443b292..1b826b0f8f 100644
@@ -4,6 +4,8 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+L3 checksum offload  = Y
+L4 checksum offload  = Y
 Link status          = P
 Linux                = Y
 Multiprocess aware   = Y
drivers/net/mana/mana.h +37 -0
index 01a3177a19..117967d856 100644
@@ -172,6 +172,11 @@ struct gdma_work_request {
 
 enum mana_cqe_type {
 	CQE_INVALID                     = 0,
+
+	CQE_RX_OKAY                     = 1,
+	CQE_RX_COALESCED_4              = 2,
+	CQE_RX_OBJECT_FENCE             = 3,
+	CQE_RX_TRUNCATED                = 4,
 };
 
 struct mana_cqe_header {
@@ -196,6 +201,35 @@ struct mana_cqe_header {
 	(NDIS_HASH_TCP_IPV4 | NDIS_HASH_UDP_IPV4 | NDIS_HASH_TCP_IPV6 |      \
 	 NDIS_HASH_UDP_IPV6 | NDIS_HASH_TCP_IPV6_EX | NDIS_HASH_UDP_IPV6_EX)
 
+struct mana_rx_comp_per_packet_info {
+	uint32_t packet_length	: 16;
+	uint32_t reserved0	: 16;
+	uint32_t reserved1;
+	uint32_t packet_hash;
+}; /* HW DATA */
+#define RX_COM_OOB_NUM_PACKETINFO_SEGMENTS 4
+
+struct mana_rx_comp_oob {
+	struct mana_cqe_header cqe_hdr;
+
+	uint32_t rx_vlan_id				: 12;
+	uint32_t rx_vlan_tag_present			: 1;
+	uint32_t rx_outer_ip_header_checksum_succeeded	: 1;
+	uint32_t rx_outer_ip_header_checksum_failed	: 1;
+	uint32_t reserved				: 1;
+	uint32_t rx_hash_type				: 9;
+	uint32_t rx_ip_header_checksum_succeeded	: 1;
+	uint32_t rx_ip_header_checksum_failed		: 1;
+	uint32_t rx_tcp_checksum_succeeded		: 1;
+	uint32_t rx_tcp_checksum_failed			: 1;
+	uint32_t rx_udp_checksum_succeeded		: 1;
+	uint32_t rx_udp_checksum_failed			: 1;
+	uint32_t reserved1				: 1;
+	struct mana_rx_comp_per_packet_info
+		packet_info[RX_COM_OOB_NUM_PACKETINFO_SEGMENTS];
+	uint32_t received_wqe_offset;
+}; /* HW DATA */
+
 struct gdma_wqe_dma_oob {
 	uint32_t reserved:24;
 	uint32_t last_v_bytes:8;
@@ -363,6 +397,9 @@ int gdma_post_work_request(struct mana_gdma_queue *queue,
 			   struct gdma_posted_wqe_info *wqe_info);
 uint8_t *gdma_get_wqe_pointer(struct mana_gdma_queue *queue);
 
+uint16_t mana_rx_burst(void *dpdk_rxq, struct rte_mbuf **rx_pkts,
+		       uint16_t pkts_n);
+
 uint16_t mana_rx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,
 			       uint16_t pkts_n);
 
drivers/net/mana/mp.c +2 -0
index a3b5ede559..feda30623a 100644
@@ -141,6 +141,8 @@ mana_mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
 	case MANA_MP_REQ_START_RXTX:
 		DRV_LOG(INFO, "Port %u starting datapath", dev->data->port_id);
 
+		dev->rx_pkt_burst = mana_rx_burst;
+
 		rte_mb();
 
 		res->result = 0;
drivers/net/mana/rx.c +105 -0

108 lines not on this page · raw message

Signature · 1 line
2.17.1
#58 lore raw

PATCH v10 15/18 net/mana: send packets

In reply to [email protected]

From: Long Li <[email protected]>

With all the TX queues created, MANA can send packets over those queues.

---
Change log:
v2: rename all camel cases.
v7: return the correct number of packets sent
v8:
fix coding style to function definitions.
change enum names to use capital letters.
v10:
remove "Free Tx mbuf on demand" from doc/guides/nics/features/mana.ini log error on doorbell failure in mana_rx_burst()

 drivers/net/mana/mana.h |  66 +++++++++++
 drivers/net/mana/mp.c   |   1 +
 drivers/net/mana/tx.c   | 249 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 316 insertions(+)
drivers/net/mana/mana.h +66 -0
index 117967d856..68352679c4 100644
@@ -56,6 +56,47 @@ struct mana_shared_data {
 
 #define NOT_USING_CLIENT_DATA_UNIT 0
 
+enum tx_packet_format_v2 {
+	SHORT_PACKET_FORMAT = 0,
+	LONG_PACKET_FORMAT = 1
+};
+
+struct transmit_short_oob_v2 {
+	enum tx_packet_format_v2 packet_format : 2;
+	uint32_t tx_is_outer_ipv4 : 1;
+	uint32_t tx_is_outer_ipv6 : 1;
+	uint32_t tx_compute_IP_header_checksum : 1;
+	uint32_t tx_compute_TCP_checksum : 1;
+	uint32_t tx_compute_UDP_checksum : 1;
+	uint32_t suppress_tx_CQE_generation : 1;
+	uint32_t VCQ_number : 24;
+	uint32_t tx_transport_header_offset : 10;
+	uint32_t VSQ_frame_num : 14;
+	uint32_t short_vport_offset : 8;
+};
+
+struct transmit_long_oob_v2 {
+	uint32_t tx_is_encapsulated_packet : 1;
+	uint32_t tx_inner_is_ipv6 : 1;
+	uint32_t tx_inner_TCP_options_present : 1;
+	uint32_t inject_vlan_prior_tag : 1;
+	uint32_t reserved1 : 12;
+	uint32_t priority_code_point : 3;
+	uint32_t drop_eligible_indicator : 1;
+	uint32_t vlan_identifier : 12;
+	uint32_t tx_inner_frame_offset : 10;
+	uint32_t tx_inner_IP_header_relative_offset : 6;
+	uint32_t long_vport_offset : 12;
+	uint32_t reserved3 : 4;
+	uint32_t reserved4 : 32;
+	uint32_t reserved5 : 32;
+};
+
+struct transmit_oob_v2 {
+	struct transmit_short_oob_v2 short_oob;
+	struct transmit_long_oob_v2 long_oob;
+};
+
 enum gdma_queue_types {
 	GDMA_QUEUE_TYPE_INVALID  = 0,
 	GDMA_QUEUE_SEND,
@@ -177,6 +218,17 @@ enum mana_cqe_type {
 	CQE_RX_COALESCED_4              = 2,
 	CQE_RX_OBJECT_FENCE             = 3,
 	CQE_RX_TRUNCATED                = 4,
+
+	CQE_TX_OKAY                     = 32,
+	CQE_TX_SA_DROP                  = 33,
+	CQE_TX_MTU_DROP                 = 34,
+	CQE_TX_INVALID_OOB              = 35,
+	CQE_TX_INVALID_ETH_TYPE         = 36,
+	CQE_TX_HDR_PROCESSING_ERROR     = 37,
+	CQE_TX_VF_DISABLED              = 38,
+	CQE_TX_VPORT_IDX_OUT_OF_RANGE   = 39,
+	CQE_TX_VPORT_DISABLED           = 40,
+	CQE_TX_VLAN_TAGGING_VIOLATION   = 41,
 };
 
 struct mana_cqe_header {
@@ -185,6 +237,17 @@ struct mana_cqe_header {
 	uint32_t vendor_err  : 24;
 }; /* HW DATA */
 
+struct mana_tx_comp_oob {
+	struct mana_cqe_header cqe_hdr;
+
+	uint32_t tx_data_offset;
+
+	uint32_t tx_sgl_offset       : 5;
+	uint32_t tx_wqe_offset       : 27;
+
+	uint32_t reserved[12];
+}; /* HW DATA */
+
 /* NDIS HASH Types */
 #define NDIS_HASH_IPV4          RTE_BIT32(0)
 #define NDIS_HASH_TCP_IPV4      RTE_BIT32(1)
@@ -348,6 +411,7 @@ struct mana_txq {
 	uint32_t desc_ring_head, desc_ring_tail;
 
 	struct mana_mr_btree mr_btree;
+	struct mana_stats stats;
 	unsigned int socket;
 };
 
@@ -399,6 +463,8 @@ uint8_t *gdma_get_wqe_pointer(struct mana_gdma_queue *queue);
 
 uint16_t mana_rx_burst(void *dpdk_rxq, struct rte_mbuf **rx_pkts,
 		       uint16_t pkts_n);
+uint16_t mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts,
+		       uint16_t pkts_n);
 
 uint16_t mana_rx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,
 			       uint16_t pkts_n);
drivers/net/mana/mp.c +1 -0
index feda30623a..92432c431d 100644
@@ -141,6 +141,7 @@ mana_mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
 	case MANA_MP_REQ_START_RXTX:
 		DRV_LOG(INFO, "Port %u starting datapath", dev->data->port_id);
 
+		dev->tx_pkt_burst = mana_tx_burst;
 		dev->rx_pkt_burst = mana_rx_burst;
 
 		rte_mb();
drivers/net/mana/tx.c +249 -0

252 lines not on this page · raw message

Signature · 1 line
2.17.1
#59 lore raw

PATCH v10 16/18 net/mana: start/stop device

In reply to [email protected]

From: Long Li <[email protected]>

Add support for starting/stopping the device.

---
Change log:
v2:
Use spinlock for memory registration cache. Add prefix mana_ to all function names.
v6:
Roll back device state on error in mana_dev_start()

 drivers/net/mana/mana.c | 77 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)
drivers/net/mana/mana.c +77 -0
index 1076f6871a..846c0ddf6c 100644
@@ -105,6 +105,81 @@ mana_dev_configure(struct rte_eth_dev *dev)
 
 static int mana_intr_uninstall(struct mana_priv *priv);
 
+static int
+mana_dev_start(struct rte_eth_dev *dev)
+{
+	int ret;
+	struct mana_priv *priv = dev->data->dev_private;
+
+	rte_spinlock_init(&priv->mr_btree_lock);
+	ret = mana_mr_btree_init(&priv->mr_btree, MANA_MR_BTREE_CACHE_N,
+				 dev->device->numa_node);
+	if (ret) {
+		DRV_LOG(ERR, "Failed to init device MR btree %d", ret);
+		return ret;
+	}
+
+	ret = mana_start_tx_queues(dev);
+	if (ret) {
+		DRV_LOG(ERR, "failed to start tx queues %d", ret);
+		goto failed_tx;
+	}
+
+	ret = mana_start_rx_queues(dev);
+	if (ret) {
+		DRV_LOG(ERR, "failed to start rx queues %d", ret);
+		goto failed_rx;
+	}
+
+	rte_wmb();
+
+	dev->tx_pkt_burst = mana_tx_burst;
+	dev->rx_pkt_burst = mana_rx_burst;
+
+	DRV_LOG(INFO, "TX/RX queues have started");
+
+	/* Enable datapath for secondary processes */
+	mana_mp_req_on_rxtx(dev, MANA_MP_REQ_START_RXTX);
+
+	return 0;
+
+failed_rx:
+	mana_stop_tx_queues(dev);
+
+failed_tx:
+	mana_mr_btree_free(&priv->mr_btree);
+
+	return ret;
+}
+
+static int
+mana_dev_stop(struct rte_eth_dev *dev __rte_unused)
+{
+	int ret;
+
+	dev->tx_pkt_burst = mana_tx_burst_removed;
+	dev->rx_pkt_burst = mana_rx_burst_removed;
+
+	/* Stop datapath on secondary processes */
+	mana_mp_req_on_rxtx(dev, MANA_MP_REQ_STOP_RXTX);
+
+	rte_wmb();
+
+	ret = mana_stop_tx_queues(dev);
+	if (ret) {
+		DRV_LOG(ERR, "failed to stop tx queues");
+		return ret;
+	}
+
+	ret = mana_stop_rx_queues(dev);
+	if (ret) {
+		DRV_LOG(ERR, "failed to stop tx queues");
+		return ret;
+	}
+
+	return 0;
+}
+
 static int
 mana_dev_close(struct rte_eth_dev *dev)
 {
@@ -453,6 +528,8 @@ mana_dev_link_update(struct rte_eth_dev *dev,
 
 static const struct eth_dev_ops mana_dev_ops = {
 	.dev_configure		= mana_dev_configure,
+	.dev_start		= mana_dev_start,
+	.dev_stop		= mana_dev_stop,
 	.dev_close		= mana_dev_close,
 	.dev_infos_get		= mana_dev_info_get,
 	.txq_info_get		= mana_dev_tx_queue_info,
Signature · 1 line
2.17.1
#60 lore raw

PATCH v10 17/18 net/mana: report queue stats

In reply to [email protected]

From: Long Li <[email protected]>

Report packet statistics.

---
Change log:
v5:
Fixed calculation of stats packets/bytes/errors by adding them over the queue stats. v8:
Fixed coding style on function definitions.

 doc/guides/nics/features/mana.ini |  1 +
 drivers/net/mana/mana.c           | 77 +++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
index 1b826b0f8f..5c19095128 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Basic stats          = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
 Link status          = P
drivers/net/mana/mana.c +77 -0

92 lines not on this page · raw message

Signature · 1 line
2.17.1
#61 lore raw

PATCH v10 18/18 net/mana: support Rx interrupts

In reply to [email protected]

From: Long Li <[email protected]>

mana can receive Rx interrupts from kernel through RDMA verbs interface. Implement Rx interrupts in the driver.

---
Change log:
v5:
New patch added to the series
v8:
Fix coding style on function definitions.

 doc/guides/nics/features/mana.ini |   1 +
 drivers/net/mana/gdma.c           |  10 +--
 drivers/net/mana/mana.c           | 125 ++++++++++++++++++++++++++----
 drivers/net/mana/mana.h           |   9 ++-
 drivers/net/mana/rx.c             |  94 +++++++++++++++++++---
 drivers/net/mana/tx.c             |   3 +-
 6 files changed, 209 insertions(+), 33 deletions(-)
doc/guides/nics/features/mana.ini +1 -0
index 5c19095128..23e71aaaae 100644
@@ -13,6 +13,7 @@ Multiprocess aware   = Y
 Queue start/stop     = Y
 Removal event        = Y
 RSS hash             = Y
+Rx interrupt         = Y
 Speed capabilities   = P
 Usage doc            = Y
 x86-64               = Y
drivers/net/mana/gdma.c +5 -5
index 370324208a..3d4039014f 100644
@@ -215,7 +215,7 @@ enum {
  */
 int
 mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
-		   uint32_t queue_id, uint32_t tail)
+		   uint32_t queue_id, uint32_t tail, uint8_t arm)
 {
 	uint8_t *addr = db_page;
 	union gdma_doorbell_entry e = {};
@@ -230,14 +230,14 @@ mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
 	case GDMA_QUEUE_RECEIVE:
 		e.rq.id = queue_id;
 		e.rq.tail_ptr = tail;
-		e.rq.wqe_cnt = 1;
+		e.rq.wqe_cnt = arm;
 		addr += DOORBELL_OFFSET_RQ;
 		break;
 
 	case GDMA_QUEUE_COMPLETION:
 		e.cq.id = queue_id;
 		e.cq.tail_ptr = tail;
-		e.cq.arm = 1;
+		e.cq.arm = arm;
 		addr += DOORBELL_OFFSET_CQ;
 		break;
 
@@ -249,8 +249,8 @@ mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
 	/* Ensure all writes are done before ringing doorbell */
 	rte_wmb();
 
-	DRV_LOG(DEBUG, "db_page %p addr %p queue_id %u type %u tail %u",
-		db_page, addr, queue_id, queue_type, tail);
+	DRV_LOG(DEBUG, "db_page %p addr %p queue_id %u type %u tail %u arm %u",
+		db_page, addr, queue_id, queue_type, tail, arm);
 
 	rte_write64(e.as_uint64, addr);
 	return 0;
drivers/net/mana/mana.c +111 -14

195 lines not on this page · raw message

drivers/net/mana/mana.h +7 -2
index 68352679c4..4a05238a96 100644
@@ -420,6 +420,7 @@ struct mana_rxq {
 	uint32_t num_desc;
 	struct rte_mempool *mp;
 	struct ibv_cq *cq;
+	struct ibv_comp_channel *channel;
 	struct ibv_wq *wq;
 
 	/* For storing pending requests */
@@ -453,8 +454,8 @@ extern int mana_logtype_init;
 #define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>")
 
 int mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
-		       uint32_t queue_id, uint32_t tail);
-int mana_rq_ring_doorbell(struct mana_rxq *rxq);
+		       uint32_t queue_id, uint32_t tail, uint8_t arm);
+int mana_rq_ring_doorbell(struct mana_rxq *rxq, uint8_t arm);
 
 int gdma_post_work_request(struct mana_gdma_queue *queue,
 			   struct gdma_work_request *work_req,
@@ -534,4 +535,8 @@ void mana_mp_req_on_rxtx(struct rte_eth_dev *dev, enum mana_mp_req_type type);
 void *mana_alloc_verbs_buf(size_t size, void *data);
 void mana_free_verbs_buf(void *ptr, void *data __rte_unused);
 
+int mana_rx_intr_enable(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int mana_rx_intr_disable(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int mana_fd_set_non_blocking(int fd);
+
 #endif
drivers/net/mana/rx.c +83 -11

145 lines not on this page · raw message

drivers/net/mana/tx.c +2 -1
index 57a682c872..300bf27cc1 100644
@@ -406,7 +406,8 @@ mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		ret = mana_ring_doorbell(db_page, GDMA_QUEUE_SEND,
 					 txq->gdma_sq.id,
 					 txq->gdma_sq.head *
-						GDMA_WQE_ALIGNMENT_UNIT_SIZE);
+						GDMA_WQE_ALIGNMENT_UNIT_SIZE,
+					 0);
 		if (ret)
 			DRV_LOG(ERR, "mana_ring_doorbell failed ret %d", ret);
 	}
Signature · 1 line
2.17.1
#62 lore raw
In reply to [email protected]
Quoted 28 lines · On 10/6/2022 12:21 AM, [email protected] wrote:

From: Long Li <[email protected]>

MANA is a network interface card to be used in the Azure cloud environment. MANA provides safe access to user memory through memory registration. It has IOMMU built into the hardware.

MANA uses IB verbs and RDMA layer to configure hardware resources. It requires the corresponding RDMA kernel-mode and user-mode drivers.

The MANA RDMA kernel-mode driver is being reviewed at:
https://patchwork.kernel.org/project/netdevbpf/list/?series=678843&state=*

The MANA RDMA user-mode driver is being reviewed at:
https://github.com/linux-rdma/rdma-core/pull/1177

Long Li (18):
net/mana: add basic driver with build environment and doc net/mana: device configuration and stop net/mana: report supported ptypes
net/mana: support link update
net/mana: support device removal interrupts net/mana: report device info
net/mana: configure RSS
net/mana: configure Rx queues
net/mana: configure Tx queues
net/mana: implement memory registration

Quoted 9 lines

net/mana: implement the hardware layer operations net/mana: start/stop Tx queues
net/mana: start/stop Rx queues
net/mana: receive packets
net/mana: send packets
net/mana: start/stop device
net/mana: report queue stats
net/mana: support Rx interrupts

Series applied to dpdk-next-net/main, thanks.

While merging, 'mana.ini' updated to keep the order same with 'default.ini, and added a brief note to release notes ('release_22_11.rst') for new driver.

#63 lore raw
Quoted 41 lines · Ferruh Yigit
Quoted 28 lines · On 10/6/2022 12:21 AM, [email protected] wrote:

From: Long Li <[email protected]>

MANA is a network interface card to be used in the Azure cloud environment. MANA provides safe access to user memory through memory registration. It has IOMMU built into the hardware.

MANA uses IB verbs and RDMA layer to configure hardware resources. It requires the corresponding RDMA kernel-mode and user-mode drivers.

The MANA RDMA kernel-mode driver is being reviewed at:
https://patchwork.kernel.org/project/netdevbpf/list/?series=678843&state=*

The MANA RDMA user-mode driver is being reviewed at:
https://github.com/linux-rdma/rdma-core/pull/1177

Long Li (18):
   net/mana: add basic driver with build environment and doc net/mana: device configuration and stop net/mana: report supported ptypes
   net/mana: support link update
   net/mana: support device removal interrupts net/mana: report device info
   net/mana: configure RSS
   net/mana: configure Rx queues
   net/mana: configure Tx queues
   net/mana: implement memory registration

Quoted 9 lines

   net/mana: implement the hardware layer operations net/mana: start/stop Tx queues
   net/mana: start/stop Rx queues
   net/mana: receive packets
   net/mana: send packets
   net/mana: start/stop device
   net/mana: report queue stats
   net/mana: support Rx interrupts

Quoted 5 lines

Series applied to dpdk-next-net/main, thanks.

While merging, 'mana.ini' updated to keep the order same with 'default.ini, and added a brief note to release notes ('release_22_11.rst') for new driver.

Since patch is merged, can you please send a patch to web mail list [1] for web repo [2], to add your device to web page [3] ? This is not urgent, sometime before release is good.

Thanks,
ferruh

[1]
https://mails.dpdk.org/listinfo/web

[2]
https://git.dpdk.org/tools/dpdk-web/tree/content/supported/nics

[3]
https://core.dpdk.org/supported/nics/

#64 lore raw
Quoted 88 lines

Subject: Re: [Patch v10 00/18] Introduce Microsoft Azure Network Adatper (MANA) PMD

Quoted 11 lines · Ferruh Yigit
Quoted 9 lines · On 10/6/2022 12:21 AM, [email protected] wrote:

From: Long Li <[email protected]>

MANA is a network interface card to be used in the Azure cloud environment.
MANA provides safe access to user memory through memory registration. It has
IOMMU built into the hardware.

Quoted 5 lines
Quoted 5 lines

MANA uses IB verbs and RDMA layer to configure hardware resources. It requires the corresponding RDMA kernel-mode and user-mode drivers.

The MANA RDMA kernel-mode driver is being reviewed at:

https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpat

Quoted 1 line
Quoted 1 line

chwork.kernel.org%2Fproject%2Fnetdevbpf%2Flist%2F%3Fseries%3D678843 %2

Quoted 1 line
Quoted 1 line

6state%3D*&amp;data=05%7C01%7Clongli%40microsoft.com%7C140c01ba7 b574c

Quoted 1 line
Quoted 1 line

1f621d08daa7bb7c4f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C 63800

Quoted 1 line
Quoted 1 line

6720966308259%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLC JQIjoiV2l

Quoted 1 line
Quoted 1 line

uMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata= sUv84%2

Quoted 4 lines
Quoted 4 lines

FrJZHT95r12YzQQlQ0MEjMZX4CHUMKw5ic5hlU%3D&amp;reserved=0

The MANA RDMA user-mode driver is being reviewed at:

https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit

Quoted 1 line
Quoted 1 line

hub.com%2Flinux-rdma%2Frdma-

core%2Fpull%2F1177&amp;data=05%7C01%7Clon

Quoted 1 line
Quoted 1 line

gli%40microsoft.com%7C140c01ba7b574c1f621d08daa7bb7c4f%7C72f988bf86 f1

Quoted 1 line
Quoted 1 line

41af91ab2d7cd011db47%7C1%7C0%7C638006720966308259%7CUnknown%7 CTWFpbGZ

Quoted 1 line
Quoted 1 line

sb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6M n0%

Quoted 1 line
Quoted 1 line

3D%7C3000%7C%7C%7C&amp;sdata=U2rw6lEbZHKqW1k%2FOWQZj7jzlyWx mfqOYnFw4P

Quoted 25 lines
Quoted 14 lines

nq9Zs%3D&amp;reserved=0

Long Li (18):
   net/mana: add basic driver with build environment and doc net/mana: device configuration and stop net/mana: report supported ptypes
   net/mana: support link update
   net/mana: support device removal interrupts net/mana: report device info
   net/mana: configure RSS
   net/mana: configure Rx queues
   net/mana: configure Tx queues
   net/mana: implement memory registration

Quoted 9 lines

   net/mana: implement the hardware layer operations net/mana: start/stop Tx queues
   net/mana: start/stop Rx queues
   net/mana: receive packets
   net/mana: send packets
   net/mana: start/stop device
   net/mana: report queue stats
   net/mana: support Rx interrupts

Quoted 6 lines

Series applied to dpdk-next-net/main, thanks.

While merging, 'mana.ini' updated to keep the order same with 'default.ini, and added a brief note to release notes ('release_22_11.rst') for new driver.

Quoted 6 lines

Since patch is merged, can you please send a patch to web mail list [1] for web repo [2], to add your device to web page [3] ?
This is not urgent, sometime before release is good.

Thanks,
Ferruh

Thank you, I will send a patch soon.

Long

Quoted 29 lines

[1]
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail
s.dpdk.org%2Flistinfo%2Fweb&amp;data=05%7C01%7Clongli%40microsoft.c om%7C140c01ba7b574c1f621d08daa7bb7c4f%7C72f988bf86f141af91ab2d7cd 011db47%7C1%7C0%7C638006720966308259%7CUnknown%7CTWFpbGZsb3d 8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0% 3D%7C3000%7C%7C%7C&amp;sdata=flufLkHYo%2BFzyHhXzi7pvzoU%2B1q% 2BGaxhoLgi%2FhHow7c%3D&amp;reserved=0

[2]
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.d
pdk.org%2Ftools%2Fdpdk- web%2Ftree%2Fcontent%2Fsupported%2Fnics&amp;data=05%7C01%7Clong li%40microsoft.com%7C140c01ba7b574c1f621d08daa7bb7c4f%7C72f988bf86f 141af91ab2d7cd011db47%7C1%7C0%7C638006720966308259%7CUnknown% 7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haW wiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=7ZoNn%2FKfjZDgkTC udS641OsIT6EInx0hIVpUcfM%2FNDA%3D&amp;reserved=0

[3]
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcore
.dpdk.org%2Fsupported%2Fnics%2F&amp;data=05%7C01%7Clongli%40micro soft.com%7C140c01ba7b574c1f621d08daa7bb7c4f%7C72f988bf86f141af91ab2 d7cd011db47%7C1%7C0%7C638006720966308259%7CUnknown%7CTWFpbGZ sb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6M n0%3D%7C3000%7C%7C%7C&amp;sdata=XxIl38Z6tWFoRZvzVGTb3JL4gZYuV n8F%2FfO%2FIYWtuAE%3D&amp;reserved=0

#65 lore raw

PATCH v7 2/18 net/mana: add device configuration and stop

In reply to [email protected]

From: Long Li <[email protected]>

MANA defines its memory allocation functions to override IB layer default functions to allocate device queues. This patch adds the code for device configuration and stop.

---
Change log:
v2:
Removed validation for offload settings in mana_dev_configure().

 drivers/net/mana/mana.c | 75 +++++++++++++++++++++++++++++++++++++++--
 drivers/net/mana/mana.h |  3 ++
 2 files changed, 76 insertions(+), 2 deletions(-)
drivers/net/mana/mana.c +73 -2
index cb59eb6882..147ab144d5 100644
@@ -40,7 +40,79 @@ static rte_spinlock_t mana_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
 int mana_logtype_driver;
 int mana_logtype_init;
 
+void *mana_alloc_verbs_buf(size_t size, void *data)
+{
+	void *ret;
+	size_t alignment = rte_mem_page_size();
+	int socket = (int)(uintptr_t)data;
+
+	DRV_LOG(DEBUG, "size=%zu socket=%d", size, socket);
+
+	if (alignment == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
+
+	ret = rte_zmalloc_socket("mana_verb_buf", size, alignment, socket);
+	if (!ret && size)
+		rte_errno = ENOMEM;
+	return ret;
+}
+
+void mana_free_verbs_buf(void *ptr, void *data __rte_unused)
+{
+	rte_free(ptr);
+}
+
+static int mana_dev_configure(struct rte_eth_dev *dev)
+{
+	struct mana_priv *priv = dev->data->dev_private;
+	struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
+
+	if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
+		dev_conf->rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH;
+
+	if (dev->data->nb_rx_queues != dev->data->nb_tx_queues) {
+		DRV_LOG(ERR, "Only support equal number of rx/tx queues");
+		return -EINVAL;
+	}
+
+	if (!rte_is_power_of_2(dev->data->nb_rx_queues)) {
+		DRV_LOG(ERR, "number of TX/RX queues must be power of 2");
+		return -EINVAL;
+	}
+
+	priv->num_queues = dev->data->nb_rx_queues;
+
+	manadv_set_context_attr(priv->ib_ctx, MANADV_CTX_ATTR_BUF_ALLOCATORS,
+				(void *)((uintptr_t)&(struct manadv_ctx_allocators){
+					.alloc = &mana_alloc_verbs_buf,
+					.free = &mana_free_verbs_buf,
+					.data = 0,
+				}));
+
+	return 0;
+}
+
+static int
+mana_dev_close(struct rte_eth_dev *dev)
+{
+	struct mana_priv *priv = dev->data->dev_private;
+	int ret;
+
+	ret = ibv_close_device(priv->ib_ctx);
+	if (ret) {
+		ret = errno;
+		return ret;
+	}
+
+	return 0;
+}
+
 const struct eth_dev_ops mana_dev_ops = {
+	.dev_configure		= mana_dev_configure,
+	.dev_close		= mana_dev_close,
 };
 
 const struct eth_dev_ops mana_dev_sec_ops = {
@@ -627,8 +699,7 @@ static int mana_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 
 static int mana_dev_uninit(struct rte_eth_dev *dev)
 {
-	RTE_SET_USED(dev);
-	return 0;
+	return mana_dev_close(dev);
 }
 
 static int mana_pci_remove(struct rte_pci_device *pci_dev)
drivers/net/mana/mana.h +3 -0
index a1184c579f..4e654e07d1 100644
@@ -206,4 +206,7 @@ int mana_mp_req_verbs_cmd_fd(struct rte_eth_dev *dev);
 
 void mana_mp_req_on_rxtx(struct rte_eth_dev *dev, enum mana_mp_req_type type);
 
+void *mana_alloc_verbs_buf(size_t size, void *data);
+void mana_free_verbs_buf(void *ptr, void *data __rte_unused);
+
 #endif
Signature · 1 line
2.17.1
#66 lore raw

PATCH v8 2/18 net/mana: add device configuration and stop

From: Long Li <[email protected]>

MANA defines its memory allocation functions to override IB layer default functions to allocate device queues. This patch adds the code for device configuration and stop.

---
v2:
Removed validation for offload settings in mana_dev_configure(). v8:
Fix coding style to function definitions.

 drivers/net/mana/mana.c | 81 ++++++++++++++++++++++++++++++++++++++++-
 drivers/net/mana/mana.h |  3 ++
 2 files changed, 82 insertions(+), 2 deletions(-)
drivers/net/mana/mana.c +79 -2
index 8b9fa9bd07..d522294bd0 100644
@@ -42,7 +42,85 @@ static rte_spinlock_t mana_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
 int mana_logtype_driver;
 int mana_logtype_init;
 
+/*
+ * Callback from rdma-core to allocate a buffer for a queue.
+ */
+void *
+mana_alloc_verbs_buf(size_t size, void *data)
+{
+	void *ret;
+	size_t alignment = rte_mem_page_size();
+	int socket = (int)(uintptr_t)data;
+
+	DRV_LOG(DEBUG, "size=%zu socket=%d", size, socket);
+
+	if (alignment == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
+
+	ret = rte_zmalloc_socket("mana_verb_buf", size, alignment, socket);
+	if (!ret && size)
+		rte_errno = ENOMEM;
+	return ret;
+}
+
+void
+mana_free_verbs_buf(void *ptr, void *data __rte_unused)
+{
+	rte_free(ptr);
+}
+
+static int
+mana_dev_configure(struct rte_eth_dev *dev)
+{
+	struct mana_priv *priv = dev->data->dev_private;
+	struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
+
+	if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
+		dev_conf->rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH;
+
+	if (dev->data->nb_rx_queues != dev->data->nb_tx_queues) {
+		DRV_LOG(ERR, "Only support equal number of rx/tx queues");
+		return -EINVAL;
+	}
+
+	if (!rte_is_power_of_2(dev->data->nb_rx_queues)) {
+		DRV_LOG(ERR, "number of TX/RX queues must be power of 2");
+		return -EINVAL;
+	}
+
+	priv->num_queues = dev->data->nb_rx_queues;
+
+	manadv_set_context_attr(priv->ib_ctx, MANADV_CTX_ATTR_BUF_ALLOCATORS,
+				(void *)((uintptr_t)&(struct manadv_ctx_allocators){
+					.alloc = &mana_alloc_verbs_buf,
+					.free = &mana_free_verbs_buf,
+					.data = 0,
+				}));
+
+	return 0;
+}
+
+static int
+mana_dev_close(struct rte_eth_dev *dev)
+{
+	struct mana_priv *priv = dev->data->dev_private;
+	int ret;
+
+	ret = ibv_close_device(priv->ib_ctx);
+	if (ret) {
+		ret = errno;
+		return ret;
+	}
+
+	return 0;
+}
+
 static const struct eth_dev_ops mana_dev_ops = {
+	.dev_configure		= mana_dev_configure,
+	.dev_close		= mana_dev_close,
 };
 
 static const struct eth_dev_ops mana_dev_secondary_ops = {
@@ -649,8 +727,7 @@ mana_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 static int
 mana_dev_uninit(struct rte_eth_dev *dev)
 {
-	RTE_SET_USED(dev);
-	return 0;
+	return mana_dev_close(dev);
 }
 
 /*
drivers/net/mana/mana.h +3 -0
index 098819e61e..d4a2fe7603 100644
@@ -204,4 +204,7 @@ int mana_mp_req_verbs_cmd_fd(struct rte_eth_dev *dev);
 
 void mana_mp_req_on_rxtx(struct rte_eth_dev *dev, enum mana_mp_req_type type);
 
+void *mana_alloc_verbs_buf(size_t size, void *data);
+void mana_free_verbs_buf(void *ptr, void *data __rte_unused);
+
 #endif
Signature · 1 line
2.17.1
#67 lore raw

PATCH v7 3/18 net/mana: add function to report support ptypes

In reply to [email protected]

From: Long Li <[email protected]>

Report supported protocol types.

---
Change log.
v7: change link_speed to RTE_ETH_SPEED_NUM_100G

 drivers/net/mana/mana.c | 16 ++++++++++++++++
 drivers/net/mana/mana.h |  2 --
 2 files changed, 16 insertions(+), 2 deletions(-)
drivers/net/mana/mana.c +16 -0
index 147ab144d5..4559632056 100644
@@ -110,9 +110,25 @@ mana_dev_close(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static const uint32_t *mana_supported_ptypes(struct rte_eth_dev *dev __rte_unused)
+{
+	static const uint32_t ptypes[] = {
+		RTE_PTYPE_L2_ETHER,
+		RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
+		RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
+		RTE_PTYPE_L4_FRAG,
+		RTE_PTYPE_L4_TCP,
+		RTE_PTYPE_L4_UDP,
+		RTE_PTYPE_UNKNOWN
+	};
+
+	return ptypes;
+}
+
 const struct eth_dev_ops mana_dev_ops = {
 	.dev_configure		= mana_dev_configure,
 	.dev_close		= mana_dev_close,
+	.dev_supported_ptypes_get = mana_supported_ptypes,
 };
 
 const struct eth_dev_ops mana_dev_sec_ops = {
drivers/net/mana/mana.h +0 -2
index 4e654e07d1..2be68093c0 100644
@@ -167,8 +167,6 @@ extern int mana_logtype_init;
 
 #define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>")
 
-const uint32_t *mana_supported_ptypes(struct rte_eth_dev *dev);
-
 uint16_t mana_rx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,
 			       uint16_t pkts_n);
 
Signature · 1 line
2.17.1
#68 lore raw

PATCH v8 3/18 net/mana: add function to report support ptypes

From: Long Li <[email protected]>

Report supported protocol types.

---
Change log.
v7: change link_speed to RTE_ETH_SPEED_NUM_100G

 drivers/net/mana/mana.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/net/mana/mana.c +17 -0
index d522294bd0..112d58a5d3 100644
@@ -118,9 +118,26 @@ mana_dev_close(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static const uint32_t *
+mana_supported_ptypes(struct rte_eth_dev *dev __rte_unused)
+{
+	static const uint32_t ptypes[] = {
+		RTE_PTYPE_L2_ETHER,
+		RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
+		RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
+		RTE_PTYPE_L4_FRAG,
+		RTE_PTYPE_L4_TCP,
+		RTE_PTYPE_L4_UDP,
+		RTE_PTYPE_UNKNOWN
+	};
+
+	return ptypes;
+}
+
 static const struct eth_dev_ops mana_dev_ops = {
 	.dev_configure		= mana_dev_configure,
 	.dev_close		= mana_dev_close,
+	.dev_supported_ptypes_get = mana_supported_ptypes,
 };
 
 static const struct eth_dev_ops mana_dev_secondary_ops = {
Signature · 1 line
2.17.1
#69 lore raw

PATCH v7 4/18 net/mana: add link update

In reply to [email protected]

From: Long Li <[email protected]>

The carrier state is managed by the Azure host. MANA runs as a VF and always reports "up".

---
 doc/guides/nics/features/mana.ini |  1 +
 drivers/net/mana/mana.c           | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
index b92a27374c..62554b0a0a 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Link status          = P
 Linux                = Y
 Multiprocess aware   = Y
 Usage doc            = Y
drivers/net/mana/mana.c +17 -0
index 4559632056..46a7bbcca0 100644
@@ -125,10 +125,27 @@ static const uint32_t *mana_supported_ptypes(struct rte_eth_dev *dev __rte_unuse
 	return ptypes;
 }
 
+static int mana_dev_link_update(struct rte_eth_dev *dev,
+				int wait_to_complete __rte_unused)
+{
+	struct rte_eth_link link;
+
+	/* MANA has no concept of carrier state, always reporting UP */
+	link = (struct rte_eth_link) {
+		.link_duplex = RTE_ETH_LINK_FULL_DUPLEX,
+		.link_autoneg = RTE_ETH_LINK_SPEED_FIXED,
+		.link_speed = RTE_ETH_SPEED_NUM_100G,
+		.link_status = RTE_ETH_LINK_UP,
+	};
+
+	return rte_eth_linkstatus_set(dev, &link);
+}
+
 const struct eth_dev_ops mana_dev_ops = {
 	.dev_configure		= mana_dev_configure,
 	.dev_close		= mana_dev_close,
 	.dev_supported_ptypes_get = mana_supported_ptypes,
+	.link_update		= mana_dev_link_update,
 };
 
 const struct eth_dev_ops mana_dev_sec_ops = {
Signature · 1 line
2.17.1
#70 lore raw

PATCH v8 4/18 net/mana: add link update

From: Long Li <[email protected]>

The carrier state is managed by the Azure host. MANA runs as a VF and always reports "up".

---
 doc/guides/nics/features/mana.ini |  1 +
 drivers/net/mana/mana.c           | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
index b92a27374c..62554b0a0a 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Link status          = P
 Linux                = Y
 Multiprocess aware   = Y
 Usage doc            = Y
drivers/net/mana/mana.c +18 -0
index 112d58a5d3..714e4ede28 100644
@@ -134,10 +134,28 @@ mana_supported_ptypes(struct rte_eth_dev *dev __rte_unused)
 	return ptypes;
 }
 
+static int
+mana_dev_link_update(struct rte_eth_dev *dev,
+		     int wait_to_complete __rte_unused)
+{
+	struct rte_eth_link link;
+
+	/* MANA has no concept of carrier state, always reporting UP */
+	link = (struct rte_eth_link) {
+		.link_duplex = RTE_ETH_LINK_FULL_DUPLEX,
+		.link_autoneg = RTE_ETH_LINK_SPEED_FIXED,
+		.link_speed = RTE_ETH_SPEED_NUM_100G,
+		.link_status = RTE_ETH_LINK_UP,
+	};
+
+	return rte_eth_linkstatus_set(dev, &link);
+}
+
 static const struct eth_dev_ops mana_dev_ops = {
 	.dev_configure		= mana_dev_configure,
 	.dev_close		= mana_dev_close,
 	.dev_supported_ptypes_get = mana_supported_ptypes,
+	.link_update		= mana_dev_link_update,
 };
 
 static const struct eth_dev_ops mana_dev_secondary_ops = {
Signature · 1 line
2.17.1
#71 lore raw

PATCH v7 5/18 net/mana: add function for device removal interrupts

In reply to [email protected]

From: Long Li <[email protected]>

MANA supports PCI hot plug events. Add this interrupt to DPDK core so its parent PMD can detect device removal during Azure servicing or live migration.

---
 doc/guides/nics/features/mana.ini |  1 +
 drivers/net/mana/mana.c           | 97 +++++++++++++++++++++++++++++++
 drivers/net/mana/mana.h           |  1 +
 3 files changed, 99 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
index 62554b0a0a..8043e11f99 100644
@@ -7,5 +7,6 @@
 Link status          = P
 Linux                = Y
 Multiprocess aware   = Y
+Removal event        = Y
 Usage doc            = Y
 x86-64               = Y
drivers/net/mana/mana.c +97 -0

121 lines not on this page · raw message

drivers/net/mana/mana.h +1 -0
index 2be68093c0..1c5ea9b44d 100644
@@ -71,6 +71,7 @@ struct mana_priv {
 	uint8_t ind_table_key[40];
 	struct ibv_qp *rwq_qp;
 	void *db_page;
+	struct rte_intr_handle *intr_handle;
 	int max_rx_queues;
 	int max_tx_queues;
 	int max_rx_desc;
Signature · 1 line
2.17.1
#72 lore raw

PATCH v8 5/18 net/mana: add function for device removal interrupts

From: Long Li <[email protected]>

MANA supports PCI hot plug events. Add this interrupt to DPDK core so its parent PMD can detect device removal during Azure servicing or live migration.

---
Change log:
v8:
fix coding style of function definitions.

 doc/guides/nics/features/mana.ini |   1 +
 drivers/net/mana/mana.c           | 103 ++++++++++++++++++++++++++++++
 drivers/net/mana/mana.h           |   1 +
 3 files changed, 105 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
index 62554b0a0a..8043e11f99 100644
@@ -7,5 +7,6 @@
 Link status          = P
 Linux                = Y
 Multiprocess aware   = Y
+Removal event        = Y
 Usage doc            = Y
 x86-64               = Y
drivers/net/mana/mana.c +103 -0

127 lines not on this page · raw message

drivers/net/mana/mana.h +1 -0
index d4a2fe7603..4a84c6e778 100644
@@ -71,6 +71,7 @@ struct mana_priv {
 	uint8_t ind_table_key[40];
 	struct ibv_qp *rwq_qp;
 	void *db_page;
+	struct rte_intr_handle *intr_handle;
 	int max_rx_queues;
 	int max_tx_queues;
 	int max_rx_desc;
Signature · 1 line
2.17.1
#73 lore raw

PATCH v7 6/18 net/mana: add device info

In reply to [email protected]

From: Long Li <[email protected]>

Add the function to get device info.

---
 doc/guides/nics/features/mana.ini |  1 +
 drivers/net/mana/mana.c           | 82 +++++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
index 8043e11f99..566b3e8770 100644
@@ -8,5 +8,6 @@ Link status          = P
 Linux                = Y
 Multiprocess aware   = Y
 Removal event        = Y
+Speed capabilities   = P
 Usage doc            = Y
 x86-64               = Y
drivers/net/mana/mana.c +82 -0

99 lines not on this page · raw message

Signature · 1 line
2.17.1
#74 lore raw

PATCH v8 6/18 net/mana: add device info

From: Long Li <[email protected]>

Add the function to get device info.

---
Change log:
v8:
use new macro definition start with "MANA_"
fix coding style to function definitions

 doc/guides/nics/features/mana.ini |  1 +
 drivers/net/mana/mana.c           | 83 +++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
index 8043e11f99..566b3e8770 100644
@@ -8,5 +8,6 @@ Link status          = P
 Linux                = Y
 Multiprocess aware   = Y
 Removal event        = Y
+Speed capabilities   = P
 Usage doc            = Y
 x86-64               = Y
drivers/net/mana/mana.c +83 -0

100 lines not on this page · raw message

Signature · 1 line
2.17.1
#75 lore raw

PATCH v7 7/18 net/mana: add function to configure RSS

In reply to [email protected]

From: Long Li <[email protected]>

Currently this PMD supports RSS configuration when the device is stopped. Configuring RSS in running state will be supported in the future.

---
 doc/guides/nics/features/mana.ini |  1 +
 drivers/net/mana/mana.c           | 61 +++++++++++++++++++++++++++++++
 drivers/net/mana/mana.h           |  1 +
 3 files changed, 63 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
index 566b3e8770..a59c21cc10 100644
@@ -8,6 +8,7 @@ Link status          = P
 Linux                = Y
 Multiprocess aware   = Y
 Removal event        = Y
+RSS hash             = Y
 Speed capabilities   = P
 Usage doc            = Y
 x86-64               = Y
drivers/net/mana/mana.c +61 -0

73 lines not on this page · raw message

drivers/net/mana/mana.h +1 -0
index 1c5ea9b44d..0eeb86f8e4 100644
@@ -71,6 +71,7 @@ struct mana_priv {
 	uint8_t ind_table_key[40];
 	struct ibv_qp *rwq_qp;
 	void *db_page;
+	struct rte_eth_rss_conf rss_conf;
 	struct rte_intr_handle *intr_handle;
 	int max_rx_queues;
 	int max_tx_queues;
Signature · 1 line
2.17.1
#76 lore raw

PATCH v8 7/18 net/mana: add function to configure RSS

From: Long Li <[email protected]>

Currently this PMD supports RSS configuration when the device is stopped. Configuring RSS in running state will be supported in the future.

---
change log:
v8:
fix coding sytle to function definitions

 doc/guides/nics/features/mana.ini |  1 +
 drivers/net/mana/mana.c           | 65 ++++++++++++++++++++++++++++++-
 drivers/net/mana/mana.h           |  1 +
 3 files changed, 66 insertions(+), 1 deletion(-)
doc/guides/nics/features/mana.ini +1 -0
index 566b3e8770..a59c21cc10 100644
@@ -8,6 +8,7 @@ Link status          = P
 Linux                = Y
 Multiprocess aware   = Y
 Removal event        = Y
+RSS hash             = Y
 Speed capabilities   = P
 Usage doc            = Y
 x86-64               = Y
drivers/net/mana/mana.c +64 -1

79 lines not on this page · raw message

drivers/net/mana/mana.h +1 -0
index 4a84c6e778..04ccdfa0d1 100644
@@ -71,6 +71,7 @@ struct mana_priv {
 	uint8_t ind_table_key[40];
 	struct ibv_qp *rwq_qp;
 	void *db_page;
+	struct rte_eth_rss_conf rss_conf;
 	struct rte_intr_handle *intr_handle;
 	int max_rx_queues;
 	int max_tx_queues;
Signature · 1 line
2.17.1
#77 lore raw

PATCH v7 8/18 net/mana: add function to configure RX queues

In reply to [email protected]

From: Long Li <[email protected]>

RX hardware queue is allocated when starting the queue. This function is for queue configuration pre starting.

---
 drivers/net/mana/mana.c | 68 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)
drivers/net/mana/mana.c +68 -0
index 2c189d371f..173b668ba2 100644
@@ -196,6 +196,16 @@ static int mana_dev_info_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static void mana_dev_rx_queue_info(struct rte_eth_dev *dev, uint16_t queue_id,
+				   struct rte_eth_rxq_info *qinfo)
+{
+	struct mana_rxq *rxq = dev->data->rx_queues[queue_id];
+
+	qinfo->mp = rxq->mp;
+	qinfo->nb_desc = rxq->num_desc;
+	qinfo->conf.offloads = dev->data->dev_conf.rxmode.offloads;
+}
+
 static const uint32_t *mana_supported_ptypes(struct rte_eth_dev *dev __rte_unused)
 {
 	static const uint32_t ptypes[] = {
@@ -270,6 +280,61 @@ static int mana_rss_hash_conf_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int mana_dev_rx_queue_setup(struct rte_eth_dev *dev,
+				   uint16_t queue_idx, uint16_t nb_desc,
+				   unsigned int socket_id,
+				   const struct rte_eth_rxconf *rx_conf __rte_unused,
+				   struct rte_mempool *mp)
+{
+	struct mana_priv *priv = dev->data->dev_private;
+	struct mana_rxq *rxq;
+	int ret;
+
+	rxq = rte_zmalloc_socket("mana_rxq", sizeof(*rxq), 0, socket_id);
+	if (!rxq) {
+		DRV_LOG(ERR, "failed to allocate rxq");
+		return -ENOMEM;
+	}
+
+	DRV_LOG(DEBUG, "idx %u nb_desc %u socket %u",
+		queue_idx, nb_desc, socket_id);
+
+	rxq->socket = socket_id;
+
+	rxq->desc_ring = rte_zmalloc_socket("mana_rx_mbuf_ring",
+					    sizeof(struct mana_rxq_desc) *
+						nb_desc,
+					    RTE_CACHE_LINE_SIZE, socket_id);
+
+	if (!rxq->desc_ring) {
+		DRV_LOG(ERR, "failed to allocate rxq desc_ring");
+		ret = -ENOMEM;
+		goto fail;
+	}
+
+	rxq->num_desc = nb_desc;
+
+	rxq->priv = priv;
+	rxq->num_desc = nb_desc;
+	rxq->mp = mp;
+	dev->data->rx_queues[queue_idx] = rxq;
+
+	return 0;
+
+fail:
+	rte_free(rxq->desc_ring);
+	rte_free(rxq);
+	return ret;
+}
+
+static void mana_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
+{
+	struct mana_rxq *rxq = dev->data->rx_queues[qid];
+
+	rte_free(rxq->desc_ring);
+	rte_free(rxq);
+}
+
 static int mana_dev_link_update(struct rte_eth_dev *dev,
 				int wait_to_complete __rte_unused)
 {
@@ -290,9 +355,12 @@ const struct eth_dev_ops mana_dev_ops = {
 	.dev_configure		= mana_dev_configure,
 	.dev_close		= mana_dev_close,
 	.dev_infos_get		= mana_dev_info_get,
+	.rxq_info_get		= mana_dev_rx_queue_info,
 	.dev_supported_ptypes_get = mana_supported_ptypes,
 	.rss_hash_update	= mana_rss_hash_update,
 	.rss_hash_conf_get	= mana_rss_hash_conf_get,
+	.rx_queue_setup		= mana_dev_rx_queue_setup,
+	.rx_queue_release	= mana_dev_rx_queue_release,
 	.link_update		= mana_dev_link_update,
 };
 
Signature · 1 line
2.17.1
#78 lore raw

PATCH v8 8/18 net/mana: add function to configure Rx queues

From: Long Li <[email protected]>

Rx hardware queue is allocated when starting the queue. This function is for queue configuration pre starting.

---
Change log:
v8:
fix coding style to function definitions

 drivers/net/mana/mana.c | 72 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 71 insertions(+), 1 deletion(-)
drivers/net/mana/mana.c +71 -1
index fe7eb19626..15bd7ea550 100644
@@ -205,6 +205,17 @@ mana_dev_info_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static void
+mana_dev_rx_queue_info(struct rte_eth_dev *dev, uint16_t queue_id,
+		       struct rte_eth_rxq_info *qinfo)
+{
+	struct mana_rxq *rxq = dev->data->rx_queues[queue_id];
+
+	qinfo->mp = rxq->mp;
+	qinfo->nb_desc = rxq->num_desc;
+	qinfo->conf.offloads = dev->data->dev_conf.rxmode.offloads;
+}
+
 static const uint32_t *
 mana_supported_ptypes(struct rte_eth_dev *dev __rte_unused)
 {
@@ -282,9 +293,65 @@ mana_rss_hash_conf_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+mana_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
+			uint16_t nb_desc, unsigned int socket_id,
+			const struct rte_eth_rxconf *rx_conf __rte_unused,
+			struct rte_mempool *mp)
+{
+	struct mana_priv *priv = dev->data->dev_private;
+	struct mana_rxq *rxq;
+	int ret;
+
+	rxq = rte_zmalloc_socket("mana_rxq", sizeof(*rxq), 0, socket_id);
+	if (!rxq) {
+		DRV_LOG(ERR, "failed to allocate rxq");
+		return -ENOMEM;
+	}
+
+	DRV_LOG(DEBUG, "idx %u nb_desc %u socket %u",
+		queue_idx, nb_desc, socket_id);
+
+	rxq->socket = socket_id;
+
+	rxq->desc_ring = rte_zmalloc_socket("mana_rx_mbuf_ring",
+					    sizeof(struct mana_rxq_desc) *
+						nb_desc,
+					    RTE_CACHE_LINE_SIZE, socket_id);
+
+	if (!rxq->desc_ring) {
+		DRV_LOG(ERR, "failed to allocate rxq desc_ring");
+		ret = -ENOMEM;
+		goto fail;
+	}
+
+	rxq->num_desc = nb_desc;
+
+	rxq->priv = priv;
+	rxq->num_desc = nb_desc;
+	rxq->mp = mp;
+	dev->data->rx_queues[queue_idx] = rxq;
+
+	return 0;
+
+fail:
+	rte_free(rxq->desc_ring);
+	rte_free(rxq);
+	return ret;
+}
+
+static void
+mana_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
+{
+	struct mana_rxq *rxq = dev->data->rx_queues[qid];
+
+	rte_free(rxq->desc_ring);
+	rte_free(rxq);
+}
+
 static int
 mana_dev_link_update(struct rte_eth_dev *dev,
-				int wait_to_complete __rte_unused)
+		     int wait_to_complete __rte_unused)
 {
 	struct rte_eth_link link;
 
@@ -303,9 +370,12 @@ static const struct eth_dev_ops mana_dev_ops = {
 	.dev_configure		= mana_dev_configure,
 	.dev_close		= mana_dev_close,
 	.dev_infos_get		= mana_dev_info_get,
+	.rxq_info_get		= mana_dev_rx_queue_info,
 	.dev_supported_ptypes_get = mana_supported_ptypes,
 	.rss_hash_update	= mana_rss_hash_update,
 	.rss_hash_conf_get	= mana_rss_hash_conf_get,
+	.rx_queue_setup		= mana_dev_rx_queue_setup,
+	.rx_queue_release	= mana_dev_rx_queue_release,
 	.link_update		= mana_dev_link_update,
 };
 
Signature · 1 line
2.17.1
#79 lore raw

PATCH v7 9/18 net/mana: add function to configure TX queues

In reply to [email protected]

From: Long Li <[email protected]>

TX hardware queue is allocated when starting the queue, this is for pre configuration.

---
 drivers/net/mana/mana.c | 65 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)
drivers/net/mana/mana.c +65 -0
index 173b668ba2..6ca708d26f 100644
@@ -196,6 +196,15 @@ static int mana_dev_info_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static void mana_dev_tx_queue_info(struct rte_eth_dev *dev, uint16_t queue_id,
+			    struct rte_eth_txq_info *qinfo)
+{
+	struct mana_txq *txq = dev->data->tx_queues[queue_id];
+
+	qinfo->conf.offloads = dev->data->dev_conf.txmode.offloads;
+	qinfo->nb_desc = txq->num_desc;
+}
+
 static void mana_dev_rx_queue_info(struct rte_eth_dev *dev, uint16_t queue_id,
 				   struct rte_eth_rxq_info *qinfo)
 {
@@ -280,6 +289,59 @@ static int mana_rss_hash_conf_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int mana_dev_tx_queue_setup(struct rte_eth_dev *dev,
+				   uint16_t queue_idx, uint16_t nb_desc,
+				   unsigned int socket_id,
+				   const struct rte_eth_txconf *tx_conf __rte_unused)
+
+{
+	struct mana_priv *priv = dev->data->dev_private;
+	struct mana_txq *txq;
+	int ret;
+
+	txq = rte_zmalloc_socket("mana_txq", sizeof(*txq), 0, socket_id);
+	if (!txq) {
+		DRV_LOG(ERR, "failed to allocate txq");
+		return -ENOMEM;
+	}
+
+	txq->socket = socket_id;
+
+	txq->desc_ring = rte_malloc_socket("mana_tx_desc_ring",
+					   sizeof(struct mana_txq_desc) *
+						nb_desc,
+					   RTE_CACHE_LINE_SIZE, socket_id);
+	if (!txq->desc_ring) {
+		DRV_LOG(ERR, "failed to allocate txq desc_ring");
+		ret = -ENOMEM;
+		goto fail;
+	}
+
+	DRV_LOG(DEBUG, "idx %u nb_desc %u socket %u txq->desc_ring %p",
+		queue_idx, nb_desc, socket_id, txq->desc_ring);
+
+	txq->desc_ring_head = 0;
+	txq->desc_ring_tail = 0;
+	txq->priv = priv;
+	txq->num_desc = nb_desc;
+	dev->data->tx_queues[queue_idx] = txq;
+
+	return 0;
+
+fail:
+	rte_free(txq->desc_ring);
+	rte_free(txq);
+	return ret;
+}
+
+static void mana_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
+{
+	struct mana_txq *txq = dev->data->tx_queues[qid];
+
+	rte_free(txq->desc_ring);
+	rte_free(txq);
+}
+
 static int mana_dev_rx_queue_setup(struct rte_eth_dev *dev,
 				   uint16_t queue_idx, uint16_t nb_desc,
 				   unsigned int socket_id,
@@ -355,10 +417,13 @@ const struct eth_dev_ops mana_dev_ops = {
 	.dev_configure		= mana_dev_configure,
 	.dev_close		= mana_dev_close,
 	.dev_infos_get		= mana_dev_info_get,
+	.txq_info_get		= mana_dev_tx_queue_info,
 	.rxq_info_get		= mana_dev_rx_queue_info,
 	.dev_supported_ptypes_get = mana_supported_ptypes,
 	.rss_hash_update	= mana_rss_hash_update,
 	.rss_hash_conf_get	= mana_rss_hash_conf_get,
+	.tx_queue_setup		= mana_dev_tx_queue_setup,
+	.tx_queue_release	= mana_dev_tx_queue_release,
 	.rx_queue_setup		= mana_dev_rx_queue_setup,
 	.rx_queue_release	= mana_dev_rx_queue_release,
 	.link_update		= mana_dev_link_update,
Signature · 1 line
2.17.1
#80 lore raw

PATCH v8 9/18 net/mana: add function to configure Tx queues

From: Long Li <[email protected]>

Tx hardware queue is allocated when starting the queue, this is for pre configuration.

---
change log:
v8:
fix coding style to function definitions

 drivers/net/mana/mana.c | 67 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
drivers/net/mana/mana.c +67 -0
index 15bd7ea550..bc8238a02b 100644
@@ -205,6 +205,16 @@ mana_dev_info_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static void
+mana_dev_tx_queue_info(struct rte_eth_dev *dev, uint16_t queue_id,
+		       struct rte_eth_txq_info *qinfo)
+{
+	struct mana_txq *txq = dev->data->tx_queues[queue_id];
+
+	qinfo->conf.offloads = dev->data->dev_conf.txmode.offloads;
+	qinfo->nb_desc = txq->num_desc;
+}
+
 static void
 mana_dev_rx_queue_info(struct rte_eth_dev *dev, uint16_t queue_id,
 		       struct rte_eth_rxq_info *qinfo)
@@ -293,6 +303,60 @@ mana_rss_hash_conf_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+mana_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
+			uint16_t nb_desc, unsigned int socket_id,
+			const struct rte_eth_txconf *tx_conf __rte_unused)
+
+{
+	struct mana_priv *priv = dev->data->dev_private;
+	struct mana_txq *txq;
+	int ret;
+
+	txq = rte_zmalloc_socket("mana_txq", sizeof(*txq), 0, socket_id);
+	if (!txq) {
+		DRV_LOG(ERR, "failed to allocate txq");
+		return -ENOMEM;
+	}
+
+	txq->socket = socket_id;
+
+	txq->desc_ring = rte_malloc_socket("mana_tx_desc_ring",
+					   sizeof(struct mana_txq_desc) *
+						nb_desc,
+					   RTE_CACHE_LINE_SIZE, socket_id);
+	if (!txq->desc_ring) {
+		DRV_LOG(ERR, "failed to allocate txq desc_ring");
+		ret = -ENOMEM;
+		goto fail;
+	}
+
+	DRV_LOG(DEBUG, "idx %u nb_desc %u socket %u txq->desc_ring %p",
+		queue_idx, nb_desc, socket_id, txq->desc_ring);
+
+	txq->desc_ring_head = 0;
+	txq->desc_ring_tail = 0;
+	txq->priv = priv;
+	txq->num_desc = nb_desc;
+	dev->data->tx_queues[queue_idx] = txq;
+
+	return 0;
+
+fail:
+	rte_free(txq->desc_ring);
+	rte_free(txq);
+	return ret;
+}
+
+static void
+mana_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
+{
+	struct mana_txq *txq = dev->data->tx_queues[qid];
+
+	rte_free(txq->desc_ring);
+	rte_free(txq);
+}
+
 static int
 mana_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
@@ -370,10 +434,13 @@ static const struct eth_dev_ops mana_dev_ops = {
 	.dev_configure		= mana_dev_configure,
 	.dev_close		= mana_dev_close,
 	.dev_infos_get		= mana_dev_info_get,
+	.txq_info_get		= mana_dev_tx_queue_info,
 	.rxq_info_get		= mana_dev_rx_queue_info,
 	.dev_supported_ptypes_get = mana_supported_ptypes,
 	.rss_hash_update	= mana_rss_hash_update,
 	.rss_hash_conf_get	= mana_rss_hash_conf_get,
+	.tx_queue_setup		= mana_dev_tx_queue_setup,
+	.tx_queue_release	= mana_dev_tx_queue_release,
 	.rx_queue_setup		= mana_dev_rx_queue_setup,
 	.rx_queue_release	= mana_dev_rx_queue_release,
 	.link_update		= mana_dev_link_update,
Signature · 1 line
2.17.1
#81 lore raw

PATCH v7 10/18 net/mana: implement memory registration

In reply to [email protected]

From: Long Li <[email protected]>

MANA hardware has iommu built-in, that provides hardware safe access to user memory through memory registration. Since memory registration is an expensive operation, this patch implements a two level memory registration cache mechanisum for each queue and for each port.

---
Change log:
v2:
Change all header file functions to start with mana_. Use spinlock in place of rwlock to memory cache access. Remove unused header files.
v4:
Remove extra "\n" in logging function.

 drivers/net/mana/mana.c      |  20 +++
 drivers/net/mana/mana.h      |  39 +++++
 drivers/net/mana/meson.build |   1 +
 drivers/net/mana/mp.c        |  85 +++++++++
 drivers/net/mana/mr.c        | 324 +++++++++++++++++++++++++++++++++++
 5 files changed, 469 insertions(+)
 create mode 100644 drivers/net/mana/mr.c
drivers/net/mana/mana.c +20 -0
index 6ca708d26f..7a48fa02aa 100644
@@ -103,6 +103,8 @@ mana_dev_close(struct rte_eth_dev *dev)
 	struct mana_priv *priv = dev->data->dev_private;
 	int ret;
 
+	mana_remove_all_mr(priv);
+
 	ret = mana_intr_uninstall(priv);
 	if (ret)
 		return ret;
@@ -317,6 +319,13 @@ static int mana_dev_tx_queue_setup(struct rte_eth_dev *dev,
 		goto fail;
 	}
 
+	ret = mana_mr_btree_init(&txq->mr_btree,
+				 MANA_MR_BTREE_PER_QUEUE_N, socket_id);
+	if (ret) {
+		DRV_LOG(ERR, "Failed to init TXQ MR btree");
+		goto fail;
+	}
+
 	DRV_LOG(DEBUG, "idx %u nb_desc %u socket %u txq->desc_ring %p",
 		queue_idx, nb_desc, socket_id, txq->desc_ring);
 
@@ -338,6 +347,8 @@ static void mana_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 {
 	struct mana_txq *txq = dev->data->tx_queues[qid];
 
+	mana_mr_btree_free(&txq->mr_btree);
+
 	rte_free(txq->desc_ring);
 	rte_free(txq);
 }
@@ -374,6 +385,13 @@ static int mana_dev_rx_queue_setup(struct rte_eth_dev *dev,
 		goto fail;
 	}
 
+	ret = mana_mr_btree_init(&rxq->mr_btree,
+				 MANA_MR_BTREE_PER_QUEUE_N, socket_id);
+	if (ret) {
+		DRV_LOG(ERR, "Failed to init RXQ MR btree");
+		goto fail;
+	}
+
 	rxq->num_desc = nb_desc;
 
 	rxq->priv = priv;
@@ -393,6 +411,8 @@ static void mana_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 {
 	struct mana_rxq *rxq = dev->data->rx_queues[qid];
 
+	mana_mr_btree_free(&rxq->mr_btree);
+
 	rte_free(rxq->desc_ring);
 	rte_free(rxq);
 }
drivers/net/mana/mana.h +39 -0
index 0eeb86f8e4..adeae1d399 100644
@@ -49,6 +49,22 @@ struct mana_shared_data {
 #define MAX_RECEIVE_BUFFERS_PER_QUEUE	256
 #define MAX_SEND_BUFFERS_PER_QUEUE	256
 
+struct mana_mr_cache {
+	uint32_t	lkey;
+	uintptr_t	addr;
+	size_t		len;
+	void		*verb_obj;
+};
+
+#define MANA_MR_BTREE_CACHE_N	512
+struct mana_mr_btree {
+	uint16_t	len;	/* Used entries */
+	uint16_t	size;	/* Total entries */
+	int		overflow;
+	int		socket;
+	struct mana_mr_cache *table;
+};
+
 struct mana_process_priv {
 	void *db_page;
 };
@@ -81,6 +97,8 @@ struct mana_priv {
 	int max_recv_sge;
 	int max_mr;
 	uint64_t max_mr_size;
+	struct mana_mr_btree mr_btree;
+	rte_spinlock_t	mr_btree_lock;
 };
 
 struct mana_txq_desc {
@@ -130,6 +148,7 @@ struct mana_txq {
 	uint32_t desc_ring_head, desc_ring_tail;
 
 	struct mana_stats stats;
+	struct mana_mr_btree mr_btree;
 	unsigned int socket;
 };
 
@@ -152,6 +171,7 @@ struct mana_rxq {
 	struct mana_gdma_queue gdma_cq;
 
 	struct mana_stats stats;
+	struct mana_mr_btree mr_btree;
 
 	unsigned int socket;
 };
@@ -175,6 +195,24 @@ uint16_t mana_rx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,
 uint16_t mana_tx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,
 			       uint16_t pkts_n);
 
+struct mana_mr_cache *mana_find_pmd_mr(struct mana_mr_btree *local_tree,
+				       struct mana_priv *priv,
+				       struct rte_mbuf *mbuf);
+int mana_new_pmd_mr(struct mana_mr_btree *local_tree, struct mana_priv *priv,
+		    struct rte_mempool *pool);
+void mana_remove_all_mr(struct mana_priv *priv);
+void mana_del_pmd_mr(struct mana_mr_cache *mr);
+
+void mana_mempool_chunk_cb(struct rte_mempool *mp, void *opaque,
+			   struct rte_mempool_memhdr *memhdr, unsigned int idx);
+
+struct mana_mr_cache *mana_mr_btree_lookup(struct mana_mr_btree *bt,
+					   uint16_t *idx,
+					   uintptr_t addr, size_t len);
+int mana_mr_btree_insert(struct mana_mr_btree *bt, struct mana_mr_cache *entry);
+int mana_mr_btree_init(struct mana_mr_btree *bt, int n, int socket);
+void mana_mr_btree_free(struct mana_mr_btree *bt);
+
 /** Request timeout for IPC. */
 #define MANA_MP_REQ_TIMEOUT_SEC 5
 
@@ -203,6 +241,7 @@ int mana_mp_init_secondary(void);
 void mana_mp_uninit_primary(void);
 void mana_mp_uninit_secondary(void);
 int mana_mp_req_verbs_cmd_fd(struct rte_eth_dev *dev);
+int mana_mp_req_mr_create(struct mana_priv *priv, uintptr_t addr, uint32_t len);
 
 void mana_mp_req_on_rxtx(struct rte_eth_dev *dev, enum mana_mp_req_type type);
 
drivers/net/mana/meson.build +1 -0
index 81c4118f53..9771394370 100644
@@ -11,6 +11,7 @@ deps += ['pci', 'bus_pci', 'net', 'eal', 'kvargs']
 
 sources += files(
 	'mana.c',
+	'mr.c',
 	'mp.c',
 )
 
drivers/net/mana/mp.c +85 -0

103 lines not on this page · raw message

drivers/net/mana/mr.c new file +324 -0

324 lines not on this page · raw message

Signature · 1 line
2.17.1
#82 lore raw

PATCH v8 10/18 net/mana: implement memory registration

From: Long Li <[email protected]>

MANA hardware has iommu built-in, that provides hardware safe access to user memory through memory registration. Since memory registration is an expensive operation, this patch implements a two level memory registration cache mechanisum for each queue and for each port.

---
Change log:
v2:
Change all header file functions to start with mana_. Use spinlock in place of rwlock to memory cache access. Remove unused header files.
v4:
Remove extra "\n" in logging function.
v8:
Fix Coding style to function definitions.

 drivers/net/mana/mana.c      |  20 ++
 drivers/net/mana/mana.h      |  39 ++++
 drivers/net/mana/meson.build |   1 +
 drivers/net/mana/mp.c        |  92 +++++++++
 drivers/net/mana/mr.c        | 348 +++++++++++++++++++++++++++++++++++
 5 files changed, 500 insertions(+)
 create mode 100644 drivers/net/mana/mr.c
drivers/net/mana/mana.c +20 -0
index bc8238a02b..67bef6bd32 100644
@@ -111,6 +111,8 @@ mana_dev_close(struct rte_eth_dev *dev)
 	struct mana_priv *priv = dev->data->dev_private;
 	int ret;
 
+	mana_remove_all_mr(priv);
+
 	ret = mana_intr_uninstall(priv);
 	if (ret)
 		return ret;
@@ -331,6 +333,13 @@ mana_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 		goto fail;
 	}
 
+	ret = mana_mr_btree_init(&txq->mr_btree,
+				 MANA_MR_BTREE_PER_QUEUE_N, socket_id);
+	if (ret) {
+		DRV_LOG(ERR, "Failed to init TXQ MR btree");
+		goto fail;
+	}
+
 	DRV_LOG(DEBUG, "idx %u nb_desc %u socket %u txq->desc_ring %p",
 		queue_idx, nb_desc, socket_id, txq->desc_ring);
 
@@ -353,6 +362,8 @@ mana_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 {
 	struct mana_txq *txq = dev->data->tx_queues[qid];
 
+	mana_mr_btree_free(&txq->mr_btree);
+
 	rte_free(txq->desc_ring);
 	rte_free(txq);
 }
@@ -389,6 +400,13 @@ mana_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 		goto fail;
 	}
 
+	ret = mana_mr_btree_init(&rxq->mr_btree,
+				 MANA_MR_BTREE_PER_QUEUE_N, socket_id);
+	if (ret) {
+		DRV_LOG(ERR, "Failed to init RXQ MR btree");
+		goto fail;
+	}
+
 	rxq->num_desc = nb_desc;
 
 	rxq->priv = priv;
@@ -409,6 +427,8 @@ mana_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 {
 	struct mana_rxq *rxq = dev->data->rx_queues[qid];
 
+	mana_mr_btree_free(&rxq->mr_btree);
+
 	rte_free(rxq->desc_ring);
 	rte_free(rxq);
 }
drivers/net/mana/mana.h +39 -0
index 04ccdfa0d1..964c30551b 100644
@@ -49,6 +49,22 @@ struct mana_shared_data {
 #define MAX_RECEIVE_BUFFERS_PER_QUEUE	256
 #define MAX_SEND_BUFFERS_PER_QUEUE	256
 
+struct mana_mr_cache {
+	uint32_t	lkey;
+	uintptr_t	addr;
+	size_t		len;
+	void		*verb_obj;
+};
+
+#define MANA_MR_BTREE_CACHE_N	512
+struct mana_mr_btree {
+	uint16_t	len;	/* Used entries */
+	uint16_t	size;	/* Total entries */
+	int		overflow;
+	int		socket;
+	struct mana_mr_cache *table;
+};
+
 struct mana_process_priv {
 	void *db_page;
 };
@@ -81,6 +97,8 @@ struct mana_priv {
 	int max_recv_sge;
 	int max_mr;
 	uint64_t max_mr_size;
+	struct mana_mr_btree mr_btree;
+	rte_spinlock_t	mr_btree_lock;
 };
 
 struct mana_txq_desc {
@@ -130,6 +148,7 @@ struct mana_txq {
 	uint32_t desc_ring_head, desc_ring_tail;
 
 	struct mana_stats stats;
+	struct mana_mr_btree mr_btree;
 	unsigned int socket;
 };
 
@@ -152,6 +171,7 @@ struct mana_rxq {
 	struct mana_gdma_queue gdma_cq;
 
 	struct mana_stats stats;
+	struct mana_mr_btree mr_btree;
 
 	unsigned int socket;
 };
@@ -175,6 +195,24 @@ uint16_t mana_rx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,
 uint16_t mana_tx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,
 			       uint16_t pkts_n);
 
+struct mana_mr_cache *mana_find_pmd_mr(struct mana_mr_btree *local_tree,
+				       struct mana_priv *priv,
+				       struct rte_mbuf *mbuf);
+int mana_new_pmd_mr(struct mana_mr_btree *local_tree, struct mana_priv *priv,
+		    struct rte_mempool *pool);
+void mana_remove_all_mr(struct mana_priv *priv);
+void mana_del_pmd_mr(struct mana_mr_cache *mr);
+
+void mana_mempool_chunk_cb(struct rte_mempool *mp, void *opaque,
+			   struct rte_mempool_memhdr *memhdr, unsigned int idx);
+
+struct mana_mr_cache *mana_mr_btree_lookup(struct mana_mr_btree *bt,
+					   uint16_t *idx,
+					   uintptr_t addr, size_t len);
+int mana_mr_btree_insert(struct mana_mr_btree *bt, struct mana_mr_cache *entry);
+int mana_mr_btree_init(struct mana_mr_btree *bt, int n, int socket);
+void mana_mr_btree_free(struct mana_mr_btree *bt);
+
 /** Request timeout for IPC. */
 #define MANA_MP_REQ_TIMEOUT_SEC 5
 
@@ -203,6 +241,7 @@ int mana_mp_init_secondary(void);
 void mana_mp_uninit_primary(void);
 void mana_mp_uninit_secondary(void);
 int mana_mp_req_verbs_cmd_fd(struct rte_eth_dev *dev);
+int mana_mp_req_mr_create(struct mana_priv *priv, uintptr_t addr, uint32_t len);
 
 void mana_mp_req_on_rxtx(struct rte_eth_dev *dev, enum mana_mp_req_type type);
 
drivers/net/mana/meson.build +1 -0
index 81c4118f53..9771394370 100644
@@ -11,6 +11,7 @@ deps += ['pci', 'bus_pci', 'net', 'eal', 'kvargs']
 
 sources += files(
 	'mana.c',
+	'mr.c',
 	'mp.c',
 )
 
drivers/net/mana/mp.c +92 -0

110 lines not on this page · raw message

drivers/net/mana/mr.c new file +348 -0

348 lines not on this page · raw message

Signature · 1 line
2.17.1
#83 lore raw

Re: [Patch v8 10/18] net/mana: implement memory registration

Quoted 6 lines · On 9/8/2022 10:58 PM, [email protected] wrote:

From: Long Li<[email protected]>

MANA hardware has iommu built-in, that provides hardware safe access to user memory through memory registration. Since memory registration is an expensive operation, this patch implements a two level memory registration cache mechanisum for each queue and for each port.

s/mechanisum/mechanism/

Quoted 2 lines

<...>

#84 lore raw

PATCH v7 11/18 net/mana: implement the hardware layer operations

In reply to [email protected]

From: Long Li <[email protected]>

The hardware layer of MANA understands the device queue and doorbell formats. Those functions are implemented for use by packet RX/TX code.

---
Change log:
v2:
Remove unused header files.
Rename a camel case.
v5:
Use RTE_BIT32() instead of defining a new BIT()
v6:
add rte_rmb() after reading owner bits

 drivers/net/mana/gdma.c      | 289 +++++++++++++++++++++++++++++++++++
 drivers/net/mana/mana.h      | 183 ++++++++++++++++++++++
 drivers/net/mana/meson.build |   1 +
 3 files changed, 473 insertions(+)
 create mode 100644 drivers/net/mana/gdma.c
drivers/net/mana/gdma.c new file +289 -0
new file mode 100644
index 0000000000..7ad175651e
@@ -0,0 +1,289 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2022 Microsoft Corporation
+ */
+
+#include <ethdev_driver.h>
+#include <rte_io.h>
+
+#include "mana.h"
+
+uint8_t *gdma_get_wqe_pointer(struct mana_gdma_queue *queue)
+{
+	uint32_t offset_in_bytes =
+		(queue->head * GDMA_WQE_ALIGNMENT_UNIT_SIZE) &
+		(queue->size - 1);
+
+	DRV_LOG(DEBUG, "txq sq_head %u sq_size %u offset_in_bytes %u",
+		queue->head, queue->size, offset_in_bytes);
+
+	if (offset_in_bytes + GDMA_WQE_ALIGNMENT_UNIT_SIZE > queue->size)
+		DRV_LOG(ERR, "fatal error: offset_in_bytes %u too big",
+			offset_in_bytes);
+
+	return ((uint8_t *)queue->buffer) + offset_in_bytes;
+}
+
+static uint32_t
+write_dma_client_oob(uint8_t *work_queue_buffer_pointer,
+		     const struct gdma_work_request *work_request,
+		     uint32_t client_oob_size)
+{
+	uint8_t *p = work_queue_buffer_pointer;
+
+	struct gdma_wqe_dma_oob *header = (struct gdma_wqe_dma_oob *)p;
+
+	memset(header, 0, sizeof(struct gdma_wqe_dma_oob));
+	header->num_sgl_entries = work_request->num_sgl_elements;
+	header->inline_client_oob_size_in_dwords =
+		client_oob_size / sizeof(uint32_t);
+	header->client_data_unit = work_request->client_data_unit;
+
+	DRV_LOG(DEBUG, "queue buf %p sgl %u oob_h %u du %u oob_buf %p oob_b %u",
+		work_queue_buffer_pointer, header->num_sgl_entries,
+		header->inline_client_oob_size_in_dwords,
+		header->client_data_unit, work_request->inline_oob_data,
+		work_request->inline_oob_size_in_bytes);
+
+	p += sizeof(struct gdma_wqe_dma_oob);
+	if (work_request->inline_oob_data &&
+	    work_request->inline_oob_size_in_bytes > 0) {
+		memcpy(p, work_request->inline_oob_data,
+		       work_request->inline_oob_size_in_bytes);
+		if (client_oob_size > work_request->inline_oob_size_in_bytes)
+			memset(p + work_request->inline_oob_size_in_bytes, 0,
+			       client_oob_size -
+			       work_request->inline_oob_size_in_bytes);
+	}
+
+	return sizeof(struct gdma_wqe_dma_oob) + client_oob_size;
+}
+
+static uint32_t
+write_scatter_gather_list(uint8_t *work_queue_head_pointer,
+			  uint8_t *work_queue_end_pointer,
+			  uint8_t *work_queue_cur_pointer,
+			  struct gdma_work_request *work_request)
+{
+	struct gdma_sgl_element *sge_list;
+	struct gdma_sgl_element dummy_sgl[1];
+	uint8_t *address;
+	uint32_t size;
+	uint32_t num_sge;
+	uint32_t size_to_queue_end;
+	uint32_t sge_list_size;
+
+	DRV_LOG(DEBUG, "work_queue_cur_pointer %p work_request->flags %x",
+		work_queue_cur_pointer, work_request->flags);
+
+	num_sge = work_request->num_sgl_elements;
+	sge_list = work_request->sgl;
+	size_to_queue_end = (uint32_t)(work_queue_end_pointer -
+				       work_queue_cur_pointer);
+
+	if (num_sge == 0) {
+		/* Per spec, the case of an empty SGL should be handled as
+		 * follows to avoid corrupted WQE errors:
+		 * Write one dummy SGL entry
+		 * Set the address to 1, leave the rest as 0
+		 */
+		dummy_sgl[num_sge].address = 1;
+		dummy_sgl[num_sge].size = 0;
+		dummy_sgl[num_sge].memory_key = 0;
+		num_sge++;
+		sge_list = dummy_sgl;
+	}
+
+	sge_list_size = 0;
+	{
+		address = (uint8_t *)sge_list;
+		size = sizeof(struct gdma_sgl_element) * num_sge;
+		if (size_to_queue_end < size) {
+			memcpy(work_queue_cur_pointer, address,
+			       size_to_queue_end);
+			work_queue_cur_pointer = work_queue_head_pointer;
+			address += size_to_queue_end;
+			size -= size_to_queue_end;
+		}
+
+		memcpy(work_queue_cur_pointer, address, size);
+		sge_list_size = size;
+	}
+
+	DRV_LOG(DEBUG, "sge %u address 0x%" PRIx64 " size %u key %u list_s %u",
+		num_sge, sge_list->address, sge_list->size,
+		sge_list->memory_key, sge_list_size);
+
+	return sge_list_size;
+}
+
+int gdma_post_work_request(struct mana_gdma_queue *queue,
+			   struct gdma_work_request *work_req,
+			   struct gdma_posted_wqe_info *wqe_info)
+{
+	uint32_t client_oob_size =
+		work_req->inline_oob_size_in_bytes >
+				INLINE_OOB_SMALL_SIZE_IN_BYTES ?
+			INLINE_OOB_LARGE_SIZE_IN_BYTES :
+			INLINE_OOB_SMALL_SIZE_IN_BYTES;
+
+	uint32_t sgl_data_size = sizeof(struct gdma_sgl_element) *
+			RTE_MAX((uint32_t)1, work_req->num_sgl_elements);
+	uint32_t wqe_size =
+		RTE_ALIGN(sizeof(struct gdma_wqe_dma_oob) +
+				client_oob_size + sgl_data_size,
+			  GDMA_WQE_ALIGNMENT_UNIT_SIZE);
+	uint8_t *wq_buffer_pointer;
+	uint32_t queue_free_units = queue->count - (queue->head - queue->tail);
+
+	if (wqe_size / GDMA_WQE_ALIGNMENT_UNIT_SIZE > queue_free_units) {
+		DRV_LOG(DEBUG, "WQE size %u queue count %u head %u tail %u",
+			wqe_size, queue->count, queue->head, queue->tail);
+		return -EBUSY;
+	}
+
+	DRV_LOG(DEBUG, "client_oob_size %u sgl_data_size %u wqe_size %u",
+		client_oob_size, sgl_data_size, wqe_size);
+
+	if (wqe_info) {
+		wqe_info->wqe_index =
+			((queue->head * GDMA_WQE_ALIGNMENT_UNIT_SIZE) &
+			 (queue->size - 1)) / GDMA_WQE_ALIGNMENT_UNIT_SIZE;
+		wqe_info->unmasked_queue_offset = queue->head;
+		wqe_info->wqe_size_in_bu =
+			wqe_size / GDMA_WQE_ALIGNMENT_UNIT_SIZE;
+	}
+
+	wq_buffer_pointer = gdma_get_wqe_pointer(queue);
+	wq_buffer_pointer += write_dma_client_oob(wq_buffer_pointer, work_req,
+						  client_oob_size);
+	if (wq_buffer_pointer >= ((uint8_t *)queue->buffer) + queue->size)
+		wq_buffer_pointer -= queue->size;
+
+	write_scatter_gather_list((uint8_t *)queue->buffer,
+				  (uint8_t *)queue->buffer + queue->size,
+				  wq_buffer_pointer, work_req);
+
+	queue->head += wqe_size / GDMA_WQE_ALIGNMENT_UNIT_SIZE;
+
+	return 0;
+}
+
+union gdma_doorbell_entry {
+	uint64_t     as_uint64;
+
+	struct {
+		uint64_t id	  : 24;
+		uint64_t reserved    : 8;
+		uint64_t tail_ptr    : 31;
+		uint64_t arm	 : 1;
+	} cq;
+
+	struct {
+		uint64_t id	  : 24;
+		uint64_t wqe_cnt     : 8;
+		uint64_t tail_ptr    : 32;
+	} rq;
+
+	struct {
+		uint64_t id	  : 24;
+		uint64_t reserved    : 8;
+		uint64_t tail_ptr    : 32;
+	} sq;
+
+	struct {
+		uint64_t id	  : 16;
+		uint64_t reserved    : 16;
+		uint64_t tail_ptr    : 31;
+		uint64_t arm	 : 1;
+	} eq;
+}; /* HW DATA */
+
+#define DOORBELL_OFFSET_SQ      0x0
+#define DOORBELL_OFFSET_RQ      0x400
+#define DOORBELL_OFFSET_CQ      0x800
+#define DOORBELL_OFFSET_EQ      0xFF8
+
+int mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
+		       uint32_t queue_id, uint32_t tail)
+{
+	uint8_t *addr = db_page;
+	union gdma_doorbell_entry e = {};
+
+	switch (queue_type) {
+	case gdma_queue_send:
+		e.sq.id = queue_id;
+		e.sq.tail_ptr = tail;
+		addr += DOORBELL_OFFSET_SQ;
+		break;
+
+	case gdma_queue_receive:
+		e.rq.id = queue_id;
+		e.rq.tail_ptr = tail;
+		e.rq.wqe_cnt = 1;
+		addr += DOORBELL_OFFSET_RQ;
+		break;
+
+	case gdma_queue_completion:
+		e.cq.id = queue_id;
+		e.cq.tail_ptr = tail;
+		e.cq.arm = 1;
+		addr += DOORBELL_OFFSET_CQ;
+		break;
+
+	default:
+		DRV_LOG(ERR, "Unsupported queue type %d", queue_type);
+		return -1;
+	}
+
+	/* Ensure all writes are done before ringing doorbell */
+	rte_wmb();
+
+	DRV_LOG(DEBUG, "db_page %p addr %p queue_id %u type %u tail %u",
+		db_page, addr, queue_id, queue_type, tail);
+
+	rte_write64(e.as_uint64, addr);
+	return 0;
+}
+
+int gdma_poll_completion_queue(struct mana_gdma_queue *cq,
+			       struct gdma_comp *comp)
+{
+	struct gdma_hardware_completion_entry *cqe;
+	uint32_t head = cq->head % cq->count;
+	uint32_t new_owner_bits, old_owner_bits;
+	uint32_t cqe_owner_bits;
+	struct gdma_hardware_completion_entry *buffer = cq->buffer;
+
+	cqe = &buffer[head];
+	new_owner_bits = (cq->head / cq->count) & COMPLETION_QUEUE_OWNER_MASK;
+	old_owner_bits = (cq->head / cq->count - 1) &
+				COMPLETION_QUEUE_OWNER_MASK;
+	cqe_owner_bits = cqe->owner_bits;
+
+	DRV_LOG(DEBUG, "comp cqe bits 0x%x owner bits 0x%x",
+		cqe_owner_bits, old_owner_bits);
+
+	if (cqe_owner_bits == old_owner_bits)
+		return 0; /* No new entry */
+
+	if (cqe_owner_bits != new_owner_bits) {
+		DRV_LOG(ERR, "CQ overflowed, ID %u cqe 0x%x new 0x%x",
+			cq->id, cqe_owner_bits, new_owner_bits);
+		return -1;
+	}
+
+	/* Ensure checking owner bits happens before reading from CQE */
+	rte_rmb();
+
+	comp->work_queue_number = cqe->wq_num;
+	comp->send_work_queue = cqe->is_sq;
+
+	memcpy(comp->completion_data, cqe->dma_client_data, GDMA_COMP_DATA_SIZE);
+
+	cq->head++;
+
+	DRV_LOG(DEBUG, "comp new 0x%x old 0x%x cqe 0x%x wq %u sq %u head %u",
+		new_owner_bits, old_owner_bits, cqe_owner_bits,
+		comp->work_queue_number, comp->send_work_queue, cq->head);
+	return 1;
+}
drivers/net/mana/mana.h +183 -0

201 lines not on this page · raw message

drivers/net/mana/meson.build +1 -0
index 9771394370..364d57a619 100644
@@ -12,6 +12,7 @@ deps += ['pci', 'bus_pci', 'net', 'eal', 'kvargs']
 sources += files(
 	'mana.c',
 	'mr.c',
+	'gdma.c',
 	'mp.c',
 )
 
Signature · 1 line
2.17.1
#85 lore raw

PATCH v8 11/18 net/mana: implement the hardware layer operations

From: Long Li <[email protected]>

The hardware layer of MANA understands the device queue and doorbell formats. Those functions are implemented for use by packet RX/TX code.

---
Change log:
v2:
Remove unused header files.
Rename a camel case.
v5:
Use RTE_BIT32() instead of defining a new BIT()
v6:
add rte_rmb() after reading owner bits
v8:
fix coding style to function definitions.
use capital letters for all enum names

 drivers/net/mana/gdma.c      | 301 +++++++++++++++++++++++++++++++++++
 drivers/net/mana/mana.h      | 183 +++++++++++++++++++++
 drivers/net/mana/meson.build |   1 +
 3 files changed, 485 insertions(+)
 create mode 100644 drivers/net/mana/gdma.c
drivers/net/mana/gdma.c new file +301 -0
new file mode 100644
index 0000000000..3f937d6c93
@@ -0,0 +1,301 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2022 Microsoft Corporation
+ */
+
+#include <ethdev_driver.h>
+#include <rte_io.h>
+
+#include "mana.h"
+
+uint8_t *
+gdma_get_wqe_pointer(struct mana_gdma_queue *queue)
+{
+	uint32_t offset_in_bytes =
+		(queue->head * GDMA_WQE_ALIGNMENT_UNIT_SIZE) &
+		(queue->size - 1);
+
+	DRV_LOG(DEBUG, "txq sq_head %u sq_size %u offset_in_bytes %u",
+		queue->head, queue->size, offset_in_bytes);
+
+	if (offset_in_bytes + GDMA_WQE_ALIGNMENT_UNIT_SIZE > queue->size)
+		DRV_LOG(ERR, "fatal error: offset_in_bytes %u too big",
+			offset_in_bytes);
+
+	return ((uint8_t *)queue->buffer) + offset_in_bytes;
+}
+
+static uint32_t
+write_dma_client_oob(uint8_t *work_queue_buffer_pointer,
+		     const struct gdma_work_request *work_request,
+		     uint32_t client_oob_size)
+{
+	uint8_t *p = work_queue_buffer_pointer;
+
+	struct gdma_wqe_dma_oob *header = (struct gdma_wqe_dma_oob *)p;
+
+	memset(header, 0, sizeof(struct gdma_wqe_dma_oob));
+	header->num_sgl_entries = work_request->num_sgl_elements;
+	header->inline_client_oob_size_in_dwords =
+		client_oob_size / sizeof(uint32_t);
+	header->client_data_unit = work_request->client_data_unit;
+
+	DRV_LOG(DEBUG, "queue buf %p sgl %u oob_h %u du %u oob_buf %p oob_b %u",
+		work_queue_buffer_pointer, header->num_sgl_entries,
+		header->inline_client_oob_size_in_dwords,
+		header->client_data_unit, work_request->inline_oob_data,
+		work_request->inline_oob_size_in_bytes);
+
+	p += sizeof(struct gdma_wqe_dma_oob);
+	if (work_request->inline_oob_data &&
+	    work_request->inline_oob_size_in_bytes > 0) {
+		memcpy(p, work_request->inline_oob_data,
+		       work_request->inline_oob_size_in_bytes);
+		if (client_oob_size > work_request->inline_oob_size_in_bytes)
+			memset(p + work_request->inline_oob_size_in_bytes, 0,
+			       client_oob_size -
+			       work_request->inline_oob_size_in_bytes);
+	}
+
+	return sizeof(struct gdma_wqe_dma_oob) + client_oob_size;
+}
+
+static uint32_t
+write_scatter_gather_list(uint8_t *work_queue_head_pointer,
+			  uint8_t *work_queue_end_pointer,
+			  uint8_t *work_queue_cur_pointer,
+			  struct gdma_work_request *work_request)
+{
+	struct gdma_sgl_element *sge_list;
+	struct gdma_sgl_element dummy_sgl[1];
+	uint8_t *address;
+	uint32_t size;
+	uint32_t num_sge;
+	uint32_t size_to_queue_end;
+	uint32_t sge_list_size;
+
+	DRV_LOG(DEBUG, "work_queue_cur_pointer %p work_request->flags %x",
+		work_queue_cur_pointer, work_request->flags);
+
+	num_sge = work_request->num_sgl_elements;
+	sge_list = work_request->sgl;
+	size_to_queue_end = (uint32_t)(work_queue_end_pointer -
+				       work_queue_cur_pointer);
+
+	if (num_sge == 0) {
+		/* Per spec, the case of an empty SGL should be handled as
+		 * follows to avoid corrupted WQE errors:
+		 * Write one dummy SGL entry
+		 * Set the address to 1, leave the rest as 0
+		 */
+		dummy_sgl[num_sge].address = 1;
+		dummy_sgl[num_sge].size = 0;
+		dummy_sgl[num_sge].memory_key = 0;
+		num_sge++;
+		sge_list = dummy_sgl;
+	}
+
+	sge_list_size = 0;
+	{
+		address = (uint8_t *)sge_list;
+		size = sizeof(struct gdma_sgl_element) * num_sge;
+		if (size_to_queue_end < size) {
+			memcpy(work_queue_cur_pointer, address,
+			       size_to_queue_end);
+			work_queue_cur_pointer = work_queue_head_pointer;
+			address += size_to_queue_end;
+			size -= size_to_queue_end;
+		}
+
+		memcpy(work_queue_cur_pointer, address, size);
+		sge_list_size = size;
+	}
+
+	DRV_LOG(DEBUG, "sge %u address 0x%" PRIx64 " size %u key %u list_s %u",
+		num_sge, sge_list->address, sge_list->size,
+		sge_list->memory_key, sge_list_size);
+
+	return sge_list_size;
+}
+
+/*
+ * Post a work request to queue.
+ */
+int
+gdma_post_work_request(struct mana_gdma_queue *queue,
+		       struct gdma_work_request *work_req,
+		       struct gdma_posted_wqe_info *wqe_info)
+{
+	uint32_t client_oob_size =
+		work_req->inline_oob_size_in_bytes >
+				INLINE_OOB_SMALL_SIZE_IN_BYTES ?
+			INLINE_OOB_LARGE_SIZE_IN_BYTES :
+			INLINE_OOB_SMALL_SIZE_IN_BYTES;
+
+	uint32_t sgl_data_size = sizeof(struct gdma_sgl_element) *
+			RTE_MAX((uint32_t)1, work_req->num_sgl_elements);
+	uint32_t wqe_size =
+		RTE_ALIGN(sizeof(struct gdma_wqe_dma_oob) +
+				client_oob_size + sgl_data_size,
+			  GDMA_WQE_ALIGNMENT_UNIT_SIZE);
+	uint8_t *wq_buffer_pointer;
+	uint32_t queue_free_units = queue->count - (queue->head - queue->tail);
+
+	if (wqe_size / GDMA_WQE_ALIGNMENT_UNIT_SIZE > queue_free_units) {
+		DRV_LOG(DEBUG, "WQE size %u queue count %u head %u tail %u",
+			wqe_size, queue->count, queue->head, queue->tail);
+		return -EBUSY;
+	}
+
+	DRV_LOG(DEBUG, "client_oob_size %u sgl_data_size %u wqe_size %u",
+		client_oob_size, sgl_data_size, wqe_size);
+
+	if (wqe_info) {
+		wqe_info->wqe_index =
+			((queue->head * GDMA_WQE_ALIGNMENT_UNIT_SIZE) &
+			 (queue->size - 1)) / GDMA_WQE_ALIGNMENT_UNIT_SIZE;
+		wqe_info->unmasked_queue_offset = queue->head;
+		wqe_info->wqe_size_in_bu =
+			wqe_size / GDMA_WQE_ALIGNMENT_UNIT_SIZE;
+	}
+
+	wq_buffer_pointer = gdma_get_wqe_pointer(queue);
+	wq_buffer_pointer += write_dma_client_oob(wq_buffer_pointer, work_req,
+						  client_oob_size);
+	if (wq_buffer_pointer >= ((uint8_t *)queue->buffer) + queue->size)
+		wq_buffer_pointer -= queue->size;
+
+	write_scatter_gather_list((uint8_t *)queue->buffer,
+				  (uint8_t *)queue->buffer + queue->size,
+				  wq_buffer_pointer, work_req);
+
+	queue->head += wqe_size / GDMA_WQE_ALIGNMENT_UNIT_SIZE;
+
+	return 0;
+}
+
+union gdma_doorbell_entry {
+	uint64_t     as_uint64;
+
+	struct {
+		uint64_t id	  : 24;
+		uint64_t reserved    : 8;
+		uint64_t tail_ptr    : 31;
+		uint64_t arm	 : 1;
+	} cq;
+
+	struct {
+		uint64_t id	  : 24;
+		uint64_t wqe_cnt     : 8;
+		uint64_t tail_ptr    : 32;
+	} rq;
+
+	struct {
+		uint64_t id	  : 24;
+		uint64_t reserved    : 8;
+		uint64_t tail_ptr    : 32;
+	} sq;
+
+	struct {
+		uint64_t id	  : 16;
+		uint64_t reserved    : 16;
+		uint64_t tail_ptr    : 31;
+		uint64_t arm	 : 1;
+	} eq;
+}; /* HW DATA */
+
+#define DOORBELL_OFFSET_SQ      0x0
+#define DOORBELL_OFFSET_RQ      0x400
+#define DOORBELL_OFFSET_CQ      0x800
+#define DOORBELL_OFFSET_EQ      0xFF8
+
+/*
+ * Write to hardware doorbell to notify new activity.
+ */
+int
+mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
+		   uint32_t queue_id, uint32_t tail)
+{
+	uint8_t *addr = db_page;
+	union gdma_doorbell_entry e = {};
+
+	switch (queue_type) {
+	case GDMA_QUEUE_SEND:
+		e.sq.id = queue_id;
+		e.sq.tail_ptr = tail;
+		addr += DOORBELL_OFFSET_SQ;
+		break;
+
+	case GDMA_QUEUE_RECEIVE:
+		e.rq.id = queue_id;
+		e.rq.tail_ptr = tail;
+		e.rq.wqe_cnt = 1;
+		addr += DOORBELL_OFFSET_RQ;
+		break;
+
+	case GDMA_QUEUE_COMPLETION:
+		e.cq.id = queue_id;
+		e.cq.tail_ptr = tail;
+		e.cq.arm = 1;
+		addr += DOORBELL_OFFSET_CQ;
+		break;
+
+	default:
+		DRV_LOG(ERR, "Unsupported queue type %d", queue_type);
+		return -1;
+	}
+
+	/* Ensure all writes are done before ringing doorbell */
+	rte_wmb();
+
+	DRV_LOG(DEBUG, "db_page %p addr %p queue_id %u type %u tail %u",
+		db_page, addr, queue_id, queue_type, tail);
+
+	rte_write64(e.as_uint64, addr);
+	return 0;
+}
+
+/*
+ * Poll completion queue for completions.
+ */
+int
+gdma_poll_completion_queue(struct mana_gdma_queue *cq, struct gdma_comp *comp)
+{
+	struct gdma_hardware_completion_entry *cqe;
+	uint32_t head = cq->head % cq->count;
+	uint32_t new_owner_bits, old_owner_bits;
+	uint32_t cqe_owner_bits;
+	struct gdma_hardware_completion_entry *buffer = cq->buffer;
+
+	cqe = &buffer[head];
+	new_owner_bits = (cq->head / cq->count) & COMPLETION_QUEUE_OWNER_MASK;
+	old_owner_bits = (cq->head / cq->count - 1) &
+				COMPLETION_QUEUE_OWNER_MASK;
+	cqe_owner_bits = cqe->owner_bits;
+
+	DRV_LOG(DEBUG, "comp cqe bits 0x%x owner bits 0x%x",
+		cqe_owner_bits, old_owner_bits);
+
+	if (cqe_owner_bits == old_owner_bits)
+		return 0; /* No new entry */
+
+	if (cqe_owner_bits != new_owner_bits) {
+		DRV_LOG(ERR, "CQ overflowed, ID %u cqe 0x%x new 0x%x",
+			cq->id, cqe_owner_bits, new_owner_bits);
+		return -1;
+	}
+
+	/* Ensure checking owner bits happens before reading from CQE */
+	rte_rmb();
+
+	comp->work_queue_number = cqe->wq_num;
+	comp->send_work_queue = cqe->is_sq;
+
+	memcpy(comp->completion_data, cqe->dma_client_data, GDMA_COMP_DATA_SIZE);
+
+	cq->head++;
+
+	DRV_LOG(DEBUG, "comp new 0x%x old 0x%x cqe 0x%x wq %u sq %u head %u",
+		new_owner_bits, old_owner_bits, cqe_owner_bits,
+		comp->work_queue_number, comp->send_work_queue, cq->head);
+	return 1;
+}
drivers/net/mana/mana.h +183 -0

201 lines not on this page · raw message

drivers/net/mana/meson.build +1 -0
index 9771394370..364d57a619 100644
@@ -12,6 +12,7 @@ deps += ['pci', 'bus_pci', 'net', 'eal', 'kvargs']
 sources += files(
 	'mana.c',
 	'mr.c',
+	'gdma.c',
 	'mp.c',
 )
 
Signature · 1 line
2.17.1
#86 lore raw

Re: [Patch v7 11/18] net/mana: implement the hardware layer operations

In reply to [email protected]
Quoted 23 lines · On 9/3/2022 2:40 AM, [email protected] wrote:

From: Long Li <[email protected]>

The hardware layer of MANA understands the device queue and doorbell formats. Those functions are implemented for use by packet RX/TX code.

---
Change log:
v2:
Remove unused header files.
Rename a camel case.
v5:
Use RTE_BIT32() instead of defining a new BIT()
v6:
add rte_rmb() after reading owner bits

  drivers/net/mana/gdma.c      | 289 +++++++++++++++++++++++++++++++++++
  drivers/net/mana/mana.h      | 183 ++++++++++++++++++++++
  drivers/net/mana/meson.build |   1 +
  3 files changed, 473 insertions(+)

create mode 100644 drivers/net/mana/gdma.c

<...>

drivers/net/mana/mana.h struct mana_shared_data { · line 198

Quoted 12 lines
drivers/net/mana/mana.h +12 -0
+
+/* NDIS HASH Types */
+#define BIT(nr)                (1 << (nr))
+#define NDIS_HASH_IPV4          BIT(0)
+#define NDIS_HASH_TCP_IPV4      BIT(1)
+#define NDIS_HASH_UDP_IPV4      BIT(2)
+#define NDIS_HASH_IPV6          BIT(3)
+#define NDIS_HASH_TCP_IPV6      BIT(4)
+#define NDIS_HASH_UDP_IPV6      BIT(5)
+#define NDIS_HASH_IPV6_EX       BIT(6)
+#define NDIS_HASH_TCP_IPV6_EX   BIT(7)
+#define NDIS_HASH_UDP_IPV6_EX   BIT(8)

v5 chagelog mentions that BIT converted to RTE_BIT32(), but I guess something went wrong and turned back to old code.

#87 lore raw

RE: [Patch v7 11/18] net/mana: implement the hardware layer operations

Quoted 32 lines

Subject: Re: [Patch v7 11/18] net/mana: implement the hardware layer operations

Quoted 17 lines · On 9/3/2022 2:40 AM, [email protected] wrote:

From: Long Li <[email protected]>

The hardware layer of MANA understands the device queue and doorbell formats. Those functions are implemented for use by packet RX/TX code.

---
Change log:
v2:
Remove unused header files.
Rename a camel case.
v5:
Use RTE_BIT32() instead of defining a new BIT()
v6:
add rte_rmb() after reading owner bits

Quoted 1 line
  drivers/net/mana/gdma.c      | 289

+++++++++++++++++++++++++++++++++++

Quoted 5 lines
  drivers/net/mana/mana.h      | 183 ++++++++++++++++++++++
  drivers/net/mana/meson.build |   1 +
  3 files changed, 473 insertions(+)

create mode 100644 drivers/net/mana/gdma.c

<...>

Quoted 16 lines

drivers/net/mana/mana.h struct mana_shared_data { · line 198

Quoted 12 lines
drivers/net/mana/mana.h +12 -0
+
+/* NDIS HASH Types */
+#define BIT(nr)                (1 << (nr))
+#define NDIS_HASH_IPV4          BIT(0)
+#define NDIS_HASH_TCP_IPV4      BIT(1)
+#define NDIS_HASH_UDP_IPV4      BIT(2)
+#define NDIS_HASH_IPV6          BIT(3)
+#define NDIS_HASH_TCP_IPV6      BIT(4)
+#define NDIS_HASH_UDP_IPV6      BIT(5)
+#define NDIS_HASH_IPV6_EX       BIT(6)
+#define NDIS_HASH_TCP_IPV6_EX   BIT(7)
+#define NDIS_HASH_UDP_IPV6_EX   BIT(8)

v5 chagelog mentions that BIT converted to RTE_BIT32(), but I guess something went wrong and turned back to old code.

Sorry it has been a rebase mishap. Will fix this.

#88 lore raw

PATCH v7 12/18 net/mana: add function to start/stop TX queues

In reply to [email protected]

From: Long Li <[email protected]>

MANA allocate device queues through the IB layer when starting TX queues. When device is stopped all the queues are unmapped and freed.

---
Change log:
v2:
Add prefix mana_ to all function names.
Remove unused header files.

 doc/guides/nics/features/mana.ini |   1 +
 drivers/net/mana/mana.h           |   4 +
 drivers/net/mana/meson.build      |   1 +
 drivers/net/mana/tx.c             | 163 ++++++++++++++++++++++++++++++
 4 files changed, 169 insertions(+)
 create mode 100644 drivers/net/mana/tx.c
doc/guides/nics/features/mana.ini +1 -0
index a59c21cc10..821443b292 100644
@@ -7,6 +7,7 @@
 Link status          = P
 Linux                = Y
 Multiprocess aware   = Y
+Queue start/stop     = Y
 Removal event        = Y
 RSS hash             = Y
 Speed capabilities   = P
drivers/net/mana/mana.h +4 -0
index 764087079f..5358bdcb77 100644
@@ -378,6 +378,10 @@ uint16_t mana_tx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,
 int gdma_poll_completion_queue(struct mana_gdma_queue *cq,
 			       struct gdma_comp *comp);
 
+int mana_start_tx_queues(struct rte_eth_dev *dev);
+
+int mana_stop_tx_queues(struct rte_eth_dev *dev);
+
 struct mana_mr_cache *mana_find_pmd_mr(struct mana_mr_btree *local_tree,
 				       struct mana_priv *priv,
 				       struct rte_mbuf *mbuf);
drivers/net/mana/meson.build +1 -0
index 364d57a619..031f443d16 100644
@@ -11,6 +11,7 @@ deps += ['pci', 'bus_pci', 'net', 'eal', 'kvargs']
 
 sources += files(
 	'mana.c',
+	'tx.c',
 	'mr.c',
 	'gdma.c',
 	'mp.c',
drivers/net/mana/tx.c new file +163 -0

163 lines not on this page · raw message

Signature · 1 line
2.17.1
#89 lore raw

PATCH v8 12/18 net/mana: add function to start/stop Tx queues

From: Long Li <[email protected]>

MANA allocate device queues through the IB layer when starting Tx queues. When device is stopped all the queues are unmapped and freed.

---
Change log:
v2:
Add prefix mana_ to all function names.
Remove unused header files.
v8:
fix coding style to function definitions.

 doc/guides/nics/features/mana.ini |   1 +
 drivers/net/mana/mana.h           |   4 +
 drivers/net/mana/meson.build      |   1 +
 drivers/net/mana/tx.c             | 166 ++++++++++++++++++++++++++++++
 4 files changed, 172 insertions(+)
 create mode 100644 drivers/net/mana/tx.c
doc/guides/nics/features/mana.ini +1 -0
index a59c21cc10..821443b292 100644
@@ -7,6 +7,7 @@
 Link status          = P
 Linux                = Y
 Multiprocess aware   = Y
+Queue start/stop     = Y
 Removal event        = Y
 RSS hash             = Y
 Speed capabilities   = P
drivers/net/mana/mana.h +4 -0
index 5abebe8e21..6a28f7c261 100644
@@ -378,6 +378,10 @@ uint16_t mana_tx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,
 int gdma_poll_completion_queue(struct mana_gdma_queue *cq,
 			       struct gdma_comp *comp);
 
+int mana_start_tx_queues(struct rte_eth_dev *dev);
+
+int mana_stop_tx_queues(struct rte_eth_dev *dev);
+
 struct mana_mr_cache *mana_find_pmd_mr(struct mana_mr_btree *local_tree,
 				       struct mana_priv *priv,
 				       struct rte_mbuf *mbuf);
drivers/net/mana/meson.build +1 -0
index 364d57a619..031f443d16 100644
@@ -11,6 +11,7 @@ deps += ['pci', 'bus_pci', 'net', 'eal', 'kvargs']
 
 sources += files(
 	'mana.c',
+	'tx.c',
 	'mr.c',
 	'gdma.c',
 	'mp.c',
drivers/net/mana/tx.c new file +166 -0

166 lines not on this page · raw message

Signature · 1 line
2.17.1
#90 lore raw

PATCH v7 13/18 net/mana: add function to start/stop RX queues

In reply to [email protected]

From: Long Li <[email protected]>

MANA allocates device queues through the IB layer when starting RX queues. When device is stopped all the queues are unmapped and freed.

---
Change log:
v2:
Add prefix mana_ to all function names.
Remove unused header files.
v4:
Move defition "uint32_t i" from inside "for ()" to outside

 drivers/net/mana/mana.h      |   3 +
 drivers/net/mana/meson.build |   1 +
 drivers/net/mana/rx.c        | 346 +++++++++++++++++++++++++++++++++++
 3 files changed, 350 insertions(+)
 create mode 100644 drivers/net/mana/rx.c
drivers/net/mana/mana.h +3 -0
index 5358bdcb77..4c37cd7df4 100644
@@ -363,6 +363,7 @@ extern int mana_logtype_init;
 
 int mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
 		       uint32_t queue_id, uint32_t tail);
+int mana_rq_ring_doorbell(struct mana_rxq *rxq);
 
 int gdma_post_work_request(struct mana_gdma_queue *queue,
 			   struct gdma_work_request *work_req,
@@ -378,8 +379,10 @@ uint16_t mana_tx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,
 int gdma_poll_completion_queue(struct mana_gdma_queue *cq,
 			       struct gdma_comp *comp);
 
+int mana_start_rx_queues(struct rte_eth_dev *dev);
 int mana_start_tx_queues(struct rte_eth_dev *dev);
 
+int mana_stop_rx_queues(struct rte_eth_dev *dev);
 int mana_stop_tx_queues(struct rte_eth_dev *dev);
 
 struct mana_mr_cache *mana_find_pmd_mr(struct mana_mr_btree *local_tree,
drivers/net/mana/meson.build +1 -0
index 031f443d16..62e103a510 100644
@@ -11,6 +11,7 @@ deps += ['pci', 'bus_pci', 'net', 'eal', 'kvargs']
 
 sources += files(
 	'mana.c',
+	'rx.c',
 	'tx.c',
 	'mr.c',
 	'gdma.c',
drivers/net/mana/rx.c new file +346 -0

346 lines not on this page · raw message

Signature · 1 line
2.17.1
#91 lore raw

PATCH v8 13/18 net/mana: add function to start/stop Rx queues

From: Long Li <[email protected]>

MANA allocates device queues through the IB layer when starting Rx queues. When device is stopped all the queues are unmapped and freed.

---
Change log:
v2:
Add prefix mana_ to all function names.
Remove unused header files.
v4:
Move defition "uint32_t i" from inside "for ()" to outside v8:
Fix coding style to function definitions.

 drivers/net/mana/mana.h      |   3 +
 drivers/net/mana/meson.build |   1 +
 drivers/net/mana/rx.c        | 354 +++++++++++++++++++++++++++++++++++
 3 files changed, 358 insertions(+)
 create mode 100644 drivers/net/mana/rx.c
drivers/net/mana/mana.h +3 -0
index 6a28f7c261..27fff35555 100644
@@ -363,6 +363,7 @@ extern int mana_logtype_init;
 
 int mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
 		       uint32_t queue_id, uint32_t tail);
+int mana_rq_ring_doorbell(struct mana_rxq *rxq);
 
 int gdma_post_work_request(struct mana_gdma_queue *queue,
 			   struct gdma_work_request *work_req,
@@ -378,8 +379,10 @@ uint16_t mana_tx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,
 int gdma_poll_completion_queue(struct mana_gdma_queue *cq,
 			       struct gdma_comp *comp);
 
+int mana_start_rx_queues(struct rte_eth_dev *dev);
 int mana_start_tx_queues(struct rte_eth_dev *dev);
 
+int mana_stop_rx_queues(struct rte_eth_dev *dev);
 int mana_stop_tx_queues(struct rte_eth_dev *dev);
 
 struct mana_mr_cache *mana_find_pmd_mr(struct mana_mr_btree *local_tree,
drivers/net/mana/meson.build +1 -0
index 031f443d16..62e103a510 100644
@@ -11,6 +11,7 @@ deps += ['pci', 'bus_pci', 'net', 'eal', 'kvargs']
 
 sources += files(
 	'mana.c',
+	'rx.c',
 	'tx.c',
 	'mr.c',
 	'gdma.c',
drivers/net/mana/rx.c new file +354 -0

354 lines not on this page · raw message

Signature · 1 line
2.17.1
#92 lore raw

PATCH v7 14/18 net/mana: add function to receive packets

In reply to [email protected]

From: Long Li <[email protected]>

With all the RX queues created, MANA can use those queues to receive packets.

---
Change log:
v2:
Add mana_ to all function names.
Rename a camel case.

 doc/guides/nics/features/mana.ini |   2 +
 drivers/net/mana/mana.c           |   2 +
 drivers/net/mana/mana.h           |  37 +++++++++++
 drivers/net/mana/mp.c             |   2 +
 drivers/net/mana/rx.c             | 104 ++++++++++++++++++++++++++++++
 5 files changed, 147 insertions(+)
doc/guides/nics/features/mana.ini +2 -0
index 821443b292..fdbf22d335 100644
@@ -6,6 +6,8 @@
 [Features]
 Link status          = P
 Linux                = Y
+L3 checksum offload  = Y
+L4 checksum offload  = Y
 Multiprocess aware   = Y
 Queue start/stop     = Y
 Removal event        = Y
drivers/net/mana/mana.c +2 -0
index 7a48fa02aa..2fd8a05658 100644
@@ -950,6 +950,8 @@ static int mana_pci_probe_mac(struct rte_pci_driver *pci_drv __rte_unused,
 				/* fd is no not used after mapping doorbell */
 				close(fd);
 
+				eth_dev->rx_pkt_burst = mana_rx_burst;
+
 				rte_spinlock_lock(&mana_shared_data->lock);
 				mana_shared_data->secondary_cnt++;
 				mana_local_data.secondary_cnt++;
drivers/net/mana/mana.h +37 -0
index 4c37cd7df4..ddc165e62f 100644
@@ -177,6 +177,11 @@ struct gdma_work_request {
 
 enum mana_cqe_type {
 	CQE_INVALID                     = 0,
+
+	CQE_RX_OKAY                     = 1,
+	CQE_RX_COALESCED_4              = 2,
+	CQE_RX_OBJECT_FENCE             = 3,
+	CQE_RX_TRUNCATED                = 4,
 };
 
 struct mana_cqe_header {
@@ -202,6 +207,35 @@ struct mana_cqe_header {
 	(NDIS_HASH_TCP_IPV4 | NDIS_HASH_UDP_IPV4 | NDIS_HASH_TCP_IPV6 |      \
 	 NDIS_HASH_UDP_IPV6 | NDIS_HASH_TCP_IPV6_EX | NDIS_HASH_UDP_IPV6_EX)
 
+struct mana_rx_comp_per_packet_info {
+	uint32_t packet_length	: 16;
+	uint32_t reserved0	: 16;
+	uint32_t reserved1;
+	uint32_t packet_hash;
+}; /* HW DATA */
+#define RX_COM_OOB_NUM_PACKETINFO_SEGMENTS 4
+
+struct mana_rx_comp_oob {
+	struct mana_cqe_header cqe_hdr;
+
+	uint32_t rx_vlan_id				: 12;
+	uint32_t rx_vlan_tag_present			: 1;
+	uint32_t rx_outer_ip_header_checksum_succeeded	: 1;
+	uint32_t rx_outer_ip_header_checksum_failed	: 1;
+	uint32_t reserved				: 1;
+	uint32_t rx_hash_type				: 9;
+	uint32_t rx_ip_header_checksum_succeeded	: 1;
+	uint32_t rx_ip_header_checksum_failed		: 1;
+	uint32_t rx_tcp_checksum_succeeded		: 1;
+	uint32_t rx_tcp_checksum_failed			: 1;
+	uint32_t rx_udp_checksum_succeeded		: 1;
+	uint32_t rx_udp_checksum_failed			: 1;
+	uint32_t reserved1				: 1;
+	struct mana_rx_comp_per_packet_info
+		packet_info[RX_COM_OOB_NUM_PACKETINFO_SEGMENTS];
+	uint32_t received_wqe_offset;
+}; /* HW DATA */
+
 struct gdma_wqe_dma_oob {
 	uint32_t reserved:24;
 	uint32_t last_v_bytes:8;
@@ -370,6 +404,9 @@ int gdma_post_work_request(struct mana_gdma_queue *queue,
 			   struct gdma_posted_wqe_info *wqe_info);
 uint8_t *gdma_get_wqe_pointer(struct mana_gdma_queue *queue);
 
+uint16_t mana_rx_burst(void *dpdk_rxq, struct rte_mbuf **rx_pkts,
+		       uint16_t pkts_n);
+
 uint16_t mana_rx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,
 			       uint16_t pkts_n);
 
drivers/net/mana/mp.c +2 -0
index f4f78d2787..36a88c561a 100644
@@ -138,6 +138,8 @@ static int mana_mp_secondary_handle(const struct rte_mp_msg *mp_msg,
 	case MANA_MP_REQ_START_RXTX:
 		DRV_LOG(INFO, "Port %u starting datapath", dev->data->port_id);
 
+		dev->rx_pkt_burst = mana_rx_burst;
+
 		rte_mb();
 
 		res->result = 0;
drivers/net/mana/rx.c +104 -0

107 lines not on this page · raw message

Signature · 1 line
2.17.1
#93 lore raw

PATCH v8 14/18 net/mana: add function to receive packets

From: Long Li <[email protected]>

With all the RX queues created, MANA can use those queues to receive packets.

---
Change log:
v2:
Add mana_ to all function names.
Rename a camel case.
v8:
Fix coding style to function definitions.

 doc/guides/nics/features/mana.ini |   2 +
 drivers/net/mana/mana.c           |   2 +
 drivers/net/mana/mana.h           |  37 +++++++++++
 drivers/net/mana/mp.c             |   2 +
 drivers/net/mana/rx.c             | 105 ++++++++++++++++++++++++++++++
 5 files changed, 148 insertions(+)
doc/guides/nics/features/mana.ini +2 -0
index 821443b292..fdbf22d335 100644
@@ -6,6 +6,8 @@
 [Features]
 Link status          = P
 Linux                = Y
+L3 checksum offload  = Y
+L4 checksum offload  = Y
 Multiprocess aware   = Y
 Queue start/stop     = Y
 Removal event        = Y
drivers/net/mana/mana.c +2 -0
index 67bef6bd32..7ed6063cc3 100644
@@ -990,6 +990,8 @@ mana_pci_probe_mac(struct rte_pci_device *pci_dev,
 				/* fd is no not used after mapping doorbell */
 				close(fd);
 
+				eth_dev->rx_pkt_burst = mana_rx_burst;
+
 				rte_spinlock_lock(&mana_shared_data->lock);
 				mana_shared_data->secondary_cnt++;
 				mana_local_data.secondary_cnt++;
drivers/net/mana/mana.h +37 -0
index 27fff35555..c2ffa14009 100644
@@ -177,6 +177,11 @@ struct gdma_work_request {
 
 enum mana_cqe_type {
 	CQE_INVALID                     = 0,
+
+	CQE_RX_OKAY                     = 1,
+	CQE_RX_COALESCED_4              = 2,
+	CQE_RX_OBJECT_FENCE             = 3,
+	CQE_RX_TRUNCATED                = 4,
 };
 
 struct mana_cqe_header {
@@ -202,6 +207,35 @@ struct mana_cqe_header {
 	(NDIS_HASH_TCP_IPV4 | NDIS_HASH_UDP_IPV4 | NDIS_HASH_TCP_IPV6 |      \
 	 NDIS_HASH_UDP_IPV6 | NDIS_HASH_TCP_IPV6_EX | NDIS_HASH_UDP_IPV6_EX)
 
+struct mana_rx_comp_per_packet_info {
+	uint32_t packet_length	: 16;
+	uint32_t reserved0	: 16;
+	uint32_t reserved1;
+	uint32_t packet_hash;
+}; /* HW DATA */
+#define RX_COM_OOB_NUM_PACKETINFO_SEGMENTS 4
+
+struct mana_rx_comp_oob {
+	struct mana_cqe_header cqe_hdr;
+
+	uint32_t rx_vlan_id				: 12;
+	uint32_t rx_vlan_tag_present			: 1;
+	uint32_t rx_outer_ip_header_checksum_succeeded	: 1;
+	uint32_t rx_outer_ip_header_checksum_failed	: 1;
+	uint32_t reserved				: 1;
+	uint32_t rx_hash_type				: 9;
+	uint32_t rx_ip_header_checksum_succeeded	: 1;
+	uint32_t rx_ip_header_checksum_failed		: 1;
+	uint32_t rx_tcp_checksum_succeeded		: 1;
+	uint32_t rx_tcp_checksum_failed			: 1;
+	uint32_t rx_udp_checksum_succeeded		: 1;
+	uint32_t rx_udp_checksum_failed			: 1;
+	uint32_t reserved1				: 1;
+	struct mana_rx_comp_per_packet_info
+		packet_info[RX_COM_OOB_NUM_PACKETINFO_SEGMENTS];
+	uint32_t received_wqe_offset;
+}; /* HW DATA */
+
 struct gdma_wqe_dma_oob {
 	uint32_t reserved:24;
 	uint32_t last_v_bytes:8;
@@ -370,6 +404,9 @@ int gdma_post_work_request(struct mana_gdma_queue *queue,
 			   struct gdma_posted_wqe_info *wqe_info);
 uint8_t *gdma_get_wqe_pointer(struct mana_gdma_queue *queue);
 
+uint16_t mana_rx_burst(void *dpdk_rxq, struct rte_mbuf **rx_pkts,
+		       uint16_t pkts_n);
+
 uint16_t mana_rx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,
 			       uint16_t pkts_n);
 
drivers/net/mana/mp.c +2 -0
index a3b5ede559..feda30623a 100644
@@ -141,6 +141,8 @@ mana_mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
 	case MANA_MP_REQ_START_RXTX:
 		DRV_LOG(INFO, "Port %u starting datapath", dev->data->port_id);
 
+		dev->rx_pkt_burst = mana_rx_burst;
+
 		rte_mb();
 
 		res->result = 0;
drivers/net/mana/rx.c +105 -0

108 lines not on this page · raw message

Signature · 1 line
2.17.1
#94 lore raw

PATCH v7 15/18 net/mana: add function to send packets

In reply to [email protected]

From: Long Li <[email protected]>

With all the TX queues created, MANA can send packets over those queues.

---
Change log:
v2: rename all camel cases.
v7: return the correct number of packets sent

 doc/guides/nics/features/mana.ini |   1 +
 drivers/net/mana/mana.c           |   1 +
 drivers/net/mana/mana.h           |  65 ++++++++
 drivers/net/mana/mp.c             |   1 +
 drivers/net/mana/tx.c             | 248 ++++++++++++++++++++++++++++++
 5 files changed, 316 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
index fdbf22d335..7922816d66 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Free Tx mbuf on demand = Y
 Link status          = P
 Linux                = Y
 L3 checksum offload  = Y
drivers/net/mana/mana.c +1 -0
index 2fd8a05658..46e064b746 100644
@@ -950,6 +950,7 @@ static int mana_pci_probe_mac(struct rte_pci_driver *pci_drv __rte_unused,
 				/* fd is no not used after mapping doorbell */
 				close(fd);
 
+				eth_dev->tx_pkt_burst = mana_tx_burst;
 				eth_dev->rx_pkt_burst = mana_rx_burst;
 
 				rte_spinlock_lock(&mana_shared_data->lock);
drivers/net/mana/mana.h +65 -0

89 lines not on this page · raw message

drivers/net/mana/mp.c +1 -0
index 36a88c561a..da9c0f36a1 100644
@@ -138,6 +138,7 @@ static int mana_mp_secondary_handle(const struct rte_mp_msg *mp_msg,
 	case MANA_MP_REQ_START_RXTX:
 		DRV_LOG(INFO, "Port %u starting datapath", dev->data->port_id);
 
+		dev->tx_pkt_burst = mana_tx_burst;
 		dev->rx_pkt_burst = mana_rx_burst;
 
 		rte_mb();
drivers/net/mana/tx.c +248 -0

251 lines not on this page · raw message

Signature · 1 line
2.17.1
#95 lore raw

PATCH v8 15/18 net/mana: add function to send packets

From: Long Li <[email protected]>

With all the TX queues created, MANA can send packets over those queues.

---
Change log:
v2: rename all camel cases.
v7: return the correct number of packets sent
v8:
fix coding style to function definitions.
change enum names to use capital letters.

 doc/guides/nics/features/mana.ini |   1 +
 drivers/net/mana/mana.c           |   1 +
 drivers/net/mana/mana.h           |  65 ++++++++
 drivers/net/mana/mp.c             |   1 +
 drivers/net/mana/tx.c             | 248 ++++++++++++++++++++++++++++++
 5 files changed, 316 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
index fdbf22d335..7922816d66 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Free Tx mbuf on demand = Y
 Link status          = P
 Linux                = Y
 L3 checksum offload  = Y
drivers/net/mana/mana.c +1 -0
index 7ed6063cc3..92692037b1 100644
@@ -990,6 +990,7 @@ mana_pci_probe_mac(struct rte_pci_device *pci_dev,
 				/* fd is no not used after mapping doorbell */
 				close(fd);
 
+				eth_dev->tx_pkt_burst = mana_tx_burst;
 				eth_dev->rx_pkt_burst = mana_rx_burst;
 
 				rte_spinlock_lock(&mana_shared_data->lock);
drivers/net/mana/mana.h +65 -0

89 lines not on this page · raw message

drivers/net/mana/mp.c +1 -0
index feda30623a..92432c431d 100644
@@ -141,6 +141,7 @@ mana_mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
 	case MANA_MP_REQ_START_RXTX:
 		DRV_LOG(INFO, "Port %u starting datapath", dev->data->port_id);
 
+		dev->tx_pkt_burst = mana_tx_burst;
 		dev->rx_pkt_burst = mana_rx_burst;
 
 		rte_mb();
drivers/net/mana/tx.c +248 -0

251 lines not on this page · raw message

Signature · 1 line
2.17.1
#96 lore raw

PATCH v7 16/18 net/mana: add function to start/stop device

In reply to [email protected]

From: Long Li <[email protected]>

Add support for starting/stopping the device.

---
Change log:
v2:
Use spinlock for memory registration cache. Add prefix mana_ to all function names.
v6:
Roll back device state on error in mana_dev_start()

 drivers/net/mana/mana.c | 77 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)
drivers/net/mana/mana.c +77 -0
index 46e064b746..856683b01c 100644
@@ -97,6 +97,81 @@ static int mana_dev_configure(struct rte_eth_dev *dev)
 
 static int mana_intr_uninstall(struct mana_priv *priv);
 
+static int
+mana_dev_start(struct rte_eth_dev *dev)
+{
+	int ret;
+	struct mana_priv *priv = dev->data->dev_private;
+
+	rte_spinlock_init(&priv->mr_btree_lock);
+	ret = mana_mr_btree_init(&priv->mr_btree, MANA_MR_BTREE_CACHE_N,
+				 dev->device->numa_node);
+	if (ret) {
+		DRV_LOG(ERR, "Failed to init device MR btree %d", ret);
+		return ret;
+	}
+
+	ret = mana_start_tx_queues(dev);
+	if (ret) {
+		DRV_LOG(ERR, "failed to start tx queues %d", ret);
+		goto failed_tx;
+	}
+
+	ret = mana_start_rx_queues(dev);
+	if (ret) {
+		DRV_LOG(ERR, "failed to start rx queues %d", ret);
+		goto failed_rx;
+	}
+
+	rte_wmb();
+
+	dev->tx_pkt_burst = mana_tx_burst;
+	dev->rx_pkt_burst = mana_rx_burst;
+
+	DRV_LOG(INFO, "TX/RX queues have started");
+
+	/* Enable datapath for secondary processes */
+	mana_mp_req_on_rxtx(dev, MANA_MP_REQ_START_RXTX);
+
+	return 0;
+
+failed_rx:
+	mana_stop_tx_queues(dev);
+
+failed_tx:
+	mana_mr_btree_free(&priv->mr_btree);
+
+	return ret;
+}
+
+static int
+mana_dev_stop(struct rte_eth_dev *dev __rte_unused)
+{
+	int ret;
+
+	dev->tx_pkt_burst = mana_tx_burst_removed;
+	dev->rx_pkt_burst = mana_rx_burst_removed;
+
+	/* Stop datapath on secondary processes */
+	mana_mp_req_on_rxtx(dev, MANA_MP_REQ_STOP_RXTX);
+
+	rte_wmb();
+
+	ret = mana_stop_tx_queues(dev);
+	if (ret) {
+		DRV_LOG(ERR, "failed to stop tx queues");
+		return ret;
+	}
+
+	ret = mana_stop_rx_queues(dev);
+	if (ret) {
+		DRV_LOG(ERR, "failed to stop tx queues");
+		return ret;
+	}
+
+	return 0;
+}
+
 static int
 mana_dev_close(struct rte_eth_dev *dev)
 {
@@ -435,6 +510,8 @@ static int mana_dev_link_update(struct rte_eth_dev *dev,
 
 const struct eth_dev_ops mana_dev_ops = {
 	.dev_configure		= mana_dev_configure,
+	.dev_start		= mana_dev_start,
+	.dev_stop		= mana_dev_stop,
 	.dev_close		= mana_dev_close,
 	.dev_infos_get		= mana_dev_info_get,
 	.txq_info_get		= mana_dev_tx_queue_info,
Signature · 1 line
2.17.1
#97 lore raw

PATCH v8 16/18 net/mana: add function to start/stop device

From: Long Li <[email protected]>

Add support for starting/stopping the device.

---
Change log:
v2:
Use spinlock for memory registration cache. Add prefix mana_ to all function names.
v6:
Roll back device state on error in mana_dev_start()

 drivers/net/mana/mana.c | 77 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)
drivers/net/mana/mana.c +77 -0
index 92692037b1..63937410b8 100644
@@ -105,6 +105,81 @@ mana_dev_configure(struct rte_eth_dev *dev)
 
 static int mana_intr_uninstall(struct mana_priv *priv);
 
+static int
+mana_dev_start(struct rte_eth_dev *dev)
+{
+	int ret;
+	struct mana_priv *priv = dev->data->dev_private;
+
+	rte_spinlock_init(&priv->mr_btree_lock);
+	ret = mana_mr_btree_init(&priv->mr_btree, MANA_MR_BTREE_CACHE_N,
+				 dev->device->numa_node);
+	if (ret) {
+		DRV_LOG(ERR, "Failed to init device MR btree %d", ret);
+		return ret;
+	}
+
+	ret = mana_start_tx_queues(dev);
+	if (ret) {
+		DRV_LOG(ERR, "failed to start tx queues %d", ret);
+		goto failed_tx;
+	}
+
+	ret = mana_start_rx_queues(dev);
+	if (ret) {
+		DRV_LOG(ERR, "failed to start rx queues %d", ret);
+		goto failed_rx;
+	}
+
+	rte_wmb();
+
+	dev->tx_pkt_burst = mana_tx_burst;
+	dev->rx_pkt_burst = mana_rx_burst;
+
+	DRV_LOG(INFO, "TX/RX queues have started");
+
+	/* Enable datapath for secondary processes */
+	mana_mp_req_on_rxtx(dev, MANA_MP_REQ_START_RXTX);
+
+	return 0;
+
+failed_rx:
+	mana_stop_tx_queues(dev);
+
+failed_tx:
+	mana_mr_btree_free(&priv->mr_btree);
+
+	return ret;
+}
+
+static int
+mana_dev_stop(struct rte_eth_dev *dev __rte_unused)
+{
+	int ret;
+
+	dev->tx_pkt_burst = mana_tx_burst_removed;
+	dev->rx_pkt_burst = mana_rx_burst_removed;
+
+	/* Stop datapath on secondary processes */
+	mana_mp_req_on_rxtx(dev, MANA_MP_REQ_STOP_RXTX);
+
+	rte_wmb();
+
+	ret = mana_stop_tx_queues(dev);
+	if (ret) {
+		DRV_LOG(ERR, "failed to stop tx queues");
+		return ret;
+	}
+
+	ret = mana_stop_rx_queues(dev);
+	if (ret) {
+		DRV_LOG(ERR, "failed to stop tx queues");
+		return ret;
+	}
+
+	return 0;
+}
+
 static int
 mana_dev_close(struct rte_eth_dev *dev)
 {
@@ -452,6 +527,8 @@ mana_dev_link_update(struct rte_eth_dev *dev,
 
 static const struct eth_dev_ops mana_dev_ops = {
 	.dev_configure		= mana_dev_configure,
+	.dev_start		= mana_dev_start,
+	.dev_stop		= mana_dev_stop,
 	.dev_close		= mana_dev_close,
 	.dev_infos_get		= mana_dev_info_get,
 	.txq_info_get		= mana_dev_tx_queue_info,
Signature · 1 line
2.17.1
#98 lore raw

PATCH v7 17/18 net/mana: add function to report queue stats

In reply to [email protected]

From: Long Li <[email protected]>

Report packet statistics.

---
Change log:
v5:
Fixed calculation of stats packets/bytes/errors by adding them over the queue stats.

 doc/guides/nics/features/mana.ini |  2 +
 drivers/net/mana/mana.c           | 77 +++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+)
doc/guides/nics/features/mana.ini +2 -0
index 7922816d66..b2729aba3a 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Basic stats          = Y
 Free Tx mbuf on demand = Y
 Link status          = P
 Linux                = Y
@@ -14,5 +15,6 @@ Queue start/stop     = Y
 Removal event        = Y
 RSS hash             = Y
 Speed capabilities   = P
+Stats per queue      = Y
 Usage doc            = Y
 x86-64               = Y
drivers/net/mana/mana.c +77 -0

92 lines not on this page · raw message

Signature · 1 line
2.17.1
#99 lore raw

PATCH v8 17/18 net/mana: add function to report queue stats

From: Long Li <[email protected]>

Report packet statistics.

---
Change log:
v5:
Fixed calculation of stats packets/bytes/errors by adding them over the queue stats. v8:
Fixed coding style on function definitions.

 doc/guides/nics/features/mana.ini |  1 +
 drivers/net/mana/mana.c           | 77 +++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
index 7922816d66..81ebc9c365 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Basic stats          = Y
 Free Tx mbuf on demand = Y
 Link status          = P
 Linux                = Y
drivers/net/mana/mana.c +77 -0

92 lines not on this page · raw message

Signature · 1 line
2.17.1
#100 lore raw

PATCH v7 18/18 net/mana: add function to support RX interrupts

In reply to [email protected]

From: Long Li <[email protected]>

mana can receive RX interrupts from kernel through RDMA verbs interface. Implement RX interrupts in the driver.

---
Change log:
v5:
New patch added to the series

 doc/guides/nics/features/mana.ini |   1 +
 drivers/net/mana/gdma.c           |  10 +--
 drivers/net/mana/mana.c           | 125 ++++++++++++++++++++++++++----
 drivers/net/mana/mana.h           |  13 +++-
 drivers/net/mana/rx.c             |  91 +++++++++++++++++++---
 drivers/net/mana/tx.c             |   3 +-
 6 files changed, 207 insertions(+), 36 deletions(-)
doc/guides/nics/features/mana.ini +1 -0
index b2729aba3a..42d78ac6b1 100644
@@ -14,6 +14,7 @@ Multiprocess aware   = Y
 Queue start/stop     = Y
 Removal event        = Y
 RSS hash             = Y
+Rx interrupt         = Y
 Speed capabilities   = P
 Stats per queue      = Y
 Usage doc            = Y
drivers/net/mana/gdma.c +5 -5
index 7ad175651e..275520bff5 100644
@@ -204,7 +204,7 @@ union gdma_doorbell_entry {
 #define DOORBELL_OFFSET_EQ      0xFF8
 
 int mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
-		       uint32_t queue_id, uint32_t tail)
+		       uint32_t queue_id, uint32_t tail, uint8_t arm)
 {
 	uint8_t *addr = db_page;
 	union gdma_doorbell_entry e = {};
@@ -219,14 +219,14 @@ int mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
 	case gdma_queue_receive:
 		e.rq.id = queue_id;
 		e.rq.tail_ptr = tail;
-		e.rq.wqe_cnt = 1;
+		e.rq.wqe_cnt = arm;
 		addr += DOORBELL_OFFSET_RQ;
 		break;
 
 	case gdma_queue_completion:
 		e.cq.id = queue_id;
 		e.cq.tail_ptr = tail;
-		e.cq.arm = 1;
+		e.cq.arm = arm;
 		addr += DOORBELL_OFFSET_CQ;
 		break;
 
@@ -238,8 +238,8 @@ int mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
 	/* Ensure all writes are done before ringing doorbell */
 	rte_wmb();
 
-	DRV_LOG(DEBUG, "db_page %p addr %p queue_id %u type %u tail %u",
-		db_page, addr, queue_id, queue_type, tail);
+	DRV_LOG(DEBUG, "db_page %p addr %p queue_id %u type %u tail %u arm %u",
+		db_page, addr, queue_id, queue_type, tail, arm);
 
 	rte_write64(e.as_uint64, addr);
 	return 0;
drivers/net/mana/mana.c +108 -17

207 lines not on this page · raw message

drivers/net/mana/mana.h +11 -2
index 9c17c1e4da..77af8ca4c0 100644
@@ -426,6 +426,7 @@ struct mana_rxq {
 	uint32_t num_desc;
 	struct rte_mempool *mp;
 	struct ibv_cq *cq;
+	struct ibv_comp_channel *channel;
 	struct ibv_wq *wq;
 
 	/* For storing pending requests */
@@ -459,8 +460,8 @@ extern int mana_logtype_init;
 #define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>")
 
 int mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
-		       uint32_t queue_id, uint32_t tail);
-int mana_rq_ring_doorbell(struct mana_rxq *rxq);
+		       uint32_t queue_id, uint32_t tail, uint8_t arm);
+int mana_rq_ring_doorbell(struct mana_rxq *rxq, uint8_t arm);
 
 int gdma_post_work_request(struct mana_gdma_queue *queue,
 			   struct gdma_work_request *work_req,
@@ -495,6 +496,10 @@ int mana_new_pmd_mr(struct mana_mr_btree *local_tree, struct mana_priv *priv,
 void mana_remove_all_mr(struct mana_priv *priv);
 void mana_del_pmd_mr(struct mana_mr_cache *mr);
 
+void mana_intr_handler(void *arg);
+int mana_intr_install(struct rte_eth_dev *eth_dev, struct mana_priv *priv);
+int mana_intr_uninstall(struct mana_priv *priv);
+
 void mana_mempool_chunk_cb(struct rte_mempool *mp, void *opaque,
 			   struct rte_mempool_memhdr *memhdr, unsigned int idx);
 
@@ -540,4 +545,8 @@ void mana_mp_req_on_rxtx(struct rte_eth_dev *dev, enum mana_mp_req_type type);
 void *mana_alloc_verbs_buf(size_t size, void *data);
 void mana_free_verbs_buf(void *ptr, void *data __rte_unused);
 
+int mana_rx_intr_enable(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int mana_rx_intr_disable(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int mana_fd_set_non_blocking(int fd);
+
 #endif
drivers/net/mana/rx.c +80 -11

142 lines not on this page · raw message

drivers/net/mana/tx.c +2 -1
index 69ae0d48f7..cae8ded1df 100644
@@ -403,7 +403,8 @@ uint16_t mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts,
 		ret = mana_ring_doorbell(db_page, gdma_queue_send,
 					 txq->gdma_sq.id,
 					 txq->gdma_sq.head *
-						GDMA_WQE_ALIGNMENT_UNIT_SIZE);
+						GDMA_WQE_ALIGNMENT_UNIT_SIZE,
+					 0);
 	if (ret)
 		DRV_LOG(ERR, "mana_ring_doorbell failed ret %d", ret);
 
Signature · 1 line
2.17.1
#101 lore raw

PATCH v8 18/18 net/mana: add function to support Rx interrupts

From: Long Li <[email protected]>

mana can receive Rx interrupts from kernel through RDMA verbs interface. Implement Rx interrupts in the driver.

---
Change log:
v5:
New patch added to the series
v8:
Fix coding style on function definitions.

 doc/guides/nics/features/mana.ini |   1 +
 drivers/net/mana/gdma.c           |  10 +--
 drivers/net/mana/mana.c           | 128 ++++++++++++++++++++++++++----
 drivers/net/mana/mana.h           |   9 ++-
 drivers/net/mana/rx.c             |  94 +++++++++++++++++++---
 drivers/net/mana/tx.c             |   3 +-
 6 files changed, 211 insertions(+), 34 deletions(-)
doc/guides/nics/features/mana.ini +1 -0
index 81ebc9c365..5fb62ea85d 100644
@@ -14,6 +14,7 @@ Multiprocess aware   = Y
 Queue start/stop     = Y
 Removal event        = Y
 RSS hash             = Y
+Rx interrupt         = Y
 Speed capabilities   = P
 Usage doc            = Y
 x86-64               = Y
drivers/net/mana/gdma.c +5 -5
index 3f937d6c93..c67c5af2f9 100644
@@ -213,7 +213,7 @@ union gdma_doorbell_entry {
  */
 int
 mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
-		   uint32_t queue_id, uint32_t tail)
+		   uint32_t queue_id, uint32_t tail, uint8_t arm)
 {
 	uint8_t *addr = db_page;
 	union gdma_doorbell_entry e = {};
@@ -228,14 +228,14 @@ mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
 	case GDMA_QUEUE_RECEIVE:
 		e.rq.id = queue_id;
 		e.rq.tail_ptr = tail;
-		e.rq.wqe_cnt = 1;
+		e.rq.wqe_cnt = arm;
 		addr += DOORBELL_OFFSET_RQ;
 		break;
 
 	case GDMA_QUEUE_COMPLETION:
 		e.cq.id = queue_id;
 		e.cq.tail_ptr = tail;
-		e.cq.arm = 1;
+		e.cq.arm = arm;
 		addr += DOORBELL_OFFSET_CQ;
 		break;
 
@@ -247,8 +247,8 @@ mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
 	/* Ensure all writes are done before ringing doorbell */
 	rte_wmb();
 
-	DRV_LOG(DEBUG, "db_page %p addr %p queue_id %u type %u tail %u",
-		db_page, addr, queue_id, queue_type, tail);
+	DRV_LOG(DEBUG, "db_page %p addr %p queue_id %u type %u tail %u arm %u",
+		db_page, addr, queue_id, queue_type, tail, arm);
 
 	rte_write64(e.as_uint64, addr);
 	return 0;
drivers/net/mana/mana.c +113 -15

205 lines not on this page · raw message

drivers/net/mana/mana.h +7 -2
index 83e3be0d6d..57fb5125bc 100644
@@ -426,6 +426,7 @@ struct mana_rxq {
 	uint32_t num_desc;
 	struct rte_mempool *mp;
 	struct ibv_cq *cq;
+	struct ibv_comp_channel *channel;
 	struct ibv_wq *wq;
 
 	/* For storing pending requests */
@@ -459,8 +460,8 @@ extern int mana_logtype_init;
 #define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>")
 
 int mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type,
-		       uint32_t queue_id, uint32_t tail);
-int mana_rq_ring_doorbell(struct mana_rxq *rxq);
+		       uint32_t queue_id, uint32_t tail, uint8_t arm);
+int mana_rq_ring_doorbell(struct mana_rxq *rxq, uint8_t arm);
 
 int gdma_post_work_request(struct mana_gdma_queue *queue,
 			   struct gdma_work_request *work_req,
@@ -540,4 +541,8 @@ void mana_mp_req_on_rxtx(struct rte_eth_dev *dev, enum mana_mp_req_type type);
 void *mana_alloc_verbs_buf(size_t size, void *data);
 void mana_free_verbs_buf(void *ptr, void *data __rte_unused);
 
+int mana_rx_intr_enable(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int mana_rx_intr_disable(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int mana_fd_set_non_blocking(int fd);
+
 #endif
drivers/net/mana/rx.c +83 -11

145 lines not on this page · raw message

drivers/net/mana/tx.c +2 -1
index 0884681c30..a92d895e54 100644
@@ -406,7 +406,8 @@ mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		ret = mana_ring_doorbell(db_page, GDMA_QUEUE_SEND,
 					 txq->gdma_sq.id,
 					 txq->gdma_sq.head *
-						GDMA_WQE_ALIGNMENT_UNIT_SIZE);
+						GDMA_WQE_ALIGNMENT_UNIT_SIZE,
+					 0);
 	if (ret)
 		DRV_LOG(ERR, "mana_ring_doorbell failed ret %d", ret);
 
Signature · 1 line
2.17.1
#102 lore raw

Re: [Patch v7 18/18] net/mana: add function to support RX interrupts

In reply to [email protected]
Quoted 6 lines · On 9/3/2022 2:41 AM, [email protected] wrote:

From: Long Li <[email protected]>

mana can receive RX interrupts from kernel through RDMA verbs interface. Implement RX interrupts in the driver.

Since there will be new version, can you please update patch title as something like following, to drop "add function to", same for all commits:
"net/mana: support RX interrupts"

Quoted 14 lines

---
Change log:
v5:
New patch added to the series

  doc/guides/nics/features/mana.ini |   1 +
  drivers/net/mana/gdma.c           |  10 +--
  drivers/net/mana/mana.c           | 125 ++++++++++++++++++++++++++----
  drivers/net/mana/mana.h           |  13 +++-
  drivers/net/mana/rx.c             |  91 +++++++++++++++++++---
  drivers/net/mana/tx.c             |   3 +-
  6 files changed, 207 insertions(+), 36 deletions(-)

<...>

#103 lore raw

RE: [Patch v7 18/18] net/mana: add function to support RX interrupts

Quoted 8 lines

Subject: Re: [Patch v7 18/18] net/mana: add function to support RX interrupts

Quoted 3 lines · On 9/3/2022 2:41 AM, [email protected] wrote:

From: Long Li <[email protected]>

Quoted 7 lines
Quoted 3 lines

mana can receive RX interrupts from kernel through RDMA verbs interface. Implement RX interrupts in the driver.

Since there will be new version, can you please update patch title as something like following, to drop "add function to", same for all commits:
"net/mana: support RX interrupts"

Sure, will send out updates.

Quoted 18 lines
Quoted 10 lines

---
Change log:
v5:
New patch added to the series

  doc/guides/nics/features/mana.ini |   1 +
  drivers/net/mana/gdma.c           |  10 +--
  drivers/net/mana/mana.c           | 125 ++++++++++++++++++++++++++---

-

Quoted 5 lines
  drivers/net/mana/mana.h           |  13 +++-
  drivers/net/mana/rx.c             |  91 +++++++++++++++++++---
  drivers/net/mana/tx.c             |   3 +-
  6 files changed, 207 insertions(+), 36 deletions(-)

<...>

#104 lore raw
In reply to [email protected]
Quoted 28 lines · On 9/3/2022 2:40 AM, [email protected] wrote:

From: Long Li <[email protected]>

MANA is a network interface card to be used in the Azure cloud environment. MANA provides safe access to user memory through memory registration. It has IOMMU built into the hardware.

MANA uses IB verbs and RDMA layer to configure hardware resources. It requires the corresponding RDMA kernel-mode and user-mode drivers.

The MANA RDMA kernel-mode driver is being reviewed at:
https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/

The MANA RDMA user-mode driver is being reviewed at:
https://github.com/linux-rdma/rdma-core/pull/1177

Long Li (18):
net/mana: add basic driver, build environment and doc net/mana: add device configuration and stop net/mana: add function to report support ptypes net/mana: add link update
net/mana: add function for device removal interrupts net/mana: add device info
net/mana: add function to configure RSS net/mana: add function to configure RX queues net/mana: add function to configure TX queues net/mana: implement memory registration

Quoted 9 lines

net/mana: implement the hardware layer operations net/mana: add function to start/stop TX queues net/mana: add function to start/stop RX queues net/mana: add function to receive packets net/mana: add function to send packets net/mana: add function to start/stop device net/mana: add function to report queue stats net/mana: add function to support RX interrupts

Can you please send new versions of the patches as reply to previous versions, so all versions can be in same thread, using git send-email '--in-reply-to' argument?

More details in the contribution guide:
https://doc.dpdk.org/guides/contributing/patches.html#sending-patches

#105 lore raw
Quoted 40 lines · Ferruh Yigit
Quoted 28 lines · On 9/3/2022 2:40 AM, [email protected] wrote:

From: Long Li <[email protected]>

MANA is a network interface card to be used in the Azure cloud environment. MANA provides safe access to user memory through memory registration. It has IOMMU built into the hardware.

MANA uses IB verbs and RDMA layer to configure hardware resources. It requires the corresponding RDMA kernel-mode and user-mode drivers.

The MANA RDMA kernel-mode driver is being reviewed at:
https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/

The MANA RDMA user-mode driver is being reviewed at:
https://github.com/linux-rdma/rdma-core/pull/1177

Long Li (18):
   net/mana: add basic driver, build environment and doc net/mana: add device configuration and stop net/mana: add function to report support ptypes net/mana: add link update
   net/mana: add function for device removal interrupts net/mana: add device info
   net/mana: add function to configure RSS net/mana: add function to configure RX queues net/mana: add function to configure TX queues net/mana: implement memory registration

Quoted 9 lines

   net/mana: implement the hardware layer operations net/mana: add function to start/stop TX queues net/mana: add function to start/stop RX queues net/mana: add function to receive packets net/mana: add function to send packets net/mana: add function to start/stop device net/mana: add function to report queue stats net/mana: add function to support RX interrupts

Quoted 5 lines

Can you please send new versions of the patches as reply to previous versions, so all versions can be in same thread, using git send-email '--in-reply-to' argument?

More details in the contribution guide:
https://doc.dpdk.org/guides/contributing/patches.html#sending-patches

Also for next version, can you please fix warnings reported by './devtools/check-git-log.sh'.

#106 lore raw
Quoted 98 lines

Subject: Re: [Patch v7 00/18] Introduce Microsoft Azure Network Adatper (MANA) PMD

Quoted 11 lines · Ferruh Yigit
Quoted 9 lines · On 9/3/2022 2:40 AM, [email protected] wrote:

From: Long Li <[email protected]>

MANA is a network interface card to be used in the Azure cloud environment.
MANA provides safe access to user memory through memory registration. It has
IOMMU built into the hardware.

Quoted 5 lines
Quoted 5 lines

MANA uses IB verbs and RDMA layer to configure hardware resources. It requires the corresponding RDMA kernel-mode and user-mode drivers.

The MANA RDMA kernel-mode driver is being reviewed at:

https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpat

Quoted 1 line
Quoted 1 line

chwork.kernel.org%2Fproject%2Fnetdevbpf%2Fcover%2F1655345240-

26411-1-

Quoted 1 line
Quoted 1 line

git-send-email-

longli%40linuxonhyperv.com%2F&amp;data=05%7C01%7Clongl

Quoted 1 line
Quoted 1 line

i%40microsoft.com%7C7b028477af2f4dc9adbb08da901578ca%7C72f988bf86f 141

Quoted 1 line
Quoted 1 line

af91ab2d7cd011db47%7C1%7C0%7C637980719147810170%7CUnknown%7CT WFpbGZsb

Quoted 1 line
Quoted 1 line

3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0 %3D

Quoted 1 line
Quoted 1 line

%7C3000%7C%7C%7C&amp;sdata=1cHl7GcqA7IVaPYeOj1Fr59%2FkkizeQij

t7Rqi6aQ

Quoted 4 lines
Quoted 4 lines

9gw%3D&amp;reserved=0

The MANA RDMA user-mode driver is being reviewed at:

https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit

Quoted 1 line
Quoted 1 line

hub.com%2Flinux-rdma%2Frdma-

core%2Fpull%2F1177&amp;data=05%7C01%7Clon

Quoted 1 line
Quoted 1 line

gli%40microsoft.com%7C7b028477af2f4dc9adbb08da901578ca%7C72f988bf86 f1

Quoted 1 line
Quoted 1 line

41af91ab2d7cd011db47%7C1%7C0%7C637980719147810170%7CUnknown%7 CTWFpbGZ

Quoted 1 line
Quoted 1 line

sb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6M n0%

Quoted 1 line
Quoted 1 line

3D%7C3000%7C%7C%7C&amp;sdata=vSWsqSZycwOIBw1hq1IZ4s3G8lXKV82J bpy99f1K

Quoted 24 lines
Quoted 14 lines

Bck%3D&amp;reserved=0

Long Li (18):
   net/mana: add basic driver, build environment and doc net/mana: add device configuration and stop net/mana: add function to report support ptypes net/mana: add link update
   net/mana: add function for device removal interrupts net/mana: add device info
   net/mana: add function to configure RSS net/mana: add function to configure RX queues net/mana: add function to configure TX queues net/mana: implement memory registration

Quoted 9 lines

   net/mana: implement the hardware layer operations net/mana: add function to start/stop TX queues net/mana: add function to start/stop RX queues net/mana: add function to receive packets net/mana: add function to send packets net/mana: add function to start/stop device net/mana: add function to report queue stats net/mana: add function to support RX interrupts

Quoted 6 lines

Can you please send new versions of the patches as reply to previous versions, so all versions can be in same thread, using git send-email '--in-reply-to' argument?

More details in the contribution guide:

https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoc.

Quoted 1 line

dpdk.org%2Fguides%2Fcontributing%2Fpatches.html%23sending-

patches&amp;

Quoted 1 line

data=05%7C01%7Clongli%40microsoft.com%7C7b028477af2f4dc9adbb08da90 1578

Quoted 1 line

ca%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C6379807191478101 70%7CU

Quoted 1 line

nknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI 6Ik1ha

Quoted 1 line
Quoted 7 lines

WwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=N0XBkRX9LdgkT2jA lPZEP6g0GB

Quoted 2 lines

aH%2ByHeG1jLHKJB6AE%3D&amp;reserved=0

Also for next version, can you please fix warnings reported by './devtools/check-git-log.sh'.

Will fix those.

#107 lore raw
In reply to Ferruh Yigit
Quoted 78 lines

Subject: Re: [Patch v7 00/18] Introduce Microsoft Azure Network Adatper (MANA) PMD

Quoted 4 lines · On 9/3/2022 2:40 AM, [email protected] wrote:

From: Long Li <[email protected]>

MANA is a network interface card to be used in the Azure cloud

environment.

Quoted 8 lines

MANA provides safe access to user memory through memory registration. It has IOMMU built into the hardware.

MANA uses IB verbs and RDMA layer to configure hardware resources. It requires the corresponding RDMA kernel-mode and user-mode drivers.

The MANA RDMA kernel-mode driver is being reviewed at:

https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatc

Quoted 1 line

hwork.kernel.org%2Fproject%2Fnetdevbpf%2Fcover%2F1655345240-

26411-1-gi

Quoted 1 line

t-send-email-

longli%40linuxonhyperv.com%2F&amp;data=05%7C01%7Clongli%4

Quoted 1 line

0microsoft.com%7C8cd6ffba9b5544435e8308da900846a8%7C72f988bf86f141 af91

Quoted 1 line

ab2d7cd011db47%7C1%7C0%7C637980662484490031%7CUnknown%7CTWFp bGZsb3d8ey

Quoted 1 line

JWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D% 7C300

Quoted 1 line

0%7C%7C%7C&amp;sdata=nr6rB9%2BN8hNV3RWhVr%2B5XgB0I5V6XtajWDz NIgF5un4%3

Quoted 4 lines

D&amp;reserved=0

The MANA RDMA user-mode driver is being reviewed at:

https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith

Quoted 1 line

ub.com%2Flinux-rdma%2Frdma-

core%2Fpull%2F1177&amp;data=05%7C01%7Clongl

Quoted 1 line

i%40microsoft.com%7C8cd6ffba9b5544435e8308da900846a8%7C72f988bf86f 141a

Quoted 1 line

f91ab2d7cd011db47%7C1%7C0%7C637980662484490031%7CUnknown%7CT WFpbGZsb3d

Quoted 1 line

8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0% 3D%7C

Quoted 1 line

3000%7C%7C%7C&amp;sdata=LNlH77y0MHa2C43j5ArWZy%2BKlMaXNpb%2F AE0am971F4

Quoted 14 lines

4%3D&amp;reserved=0

Long Li (18):
net/mana: add basic driver, build environment and doc net/mana: add device configuration and stop net/mana: add function to report support ptypes net/mana: add link update
net/mana: add function for device removal interrupts net/mana: add device info
net/mana: add function to configure RSS net/mana: add function to configure RX queues net/mana: add function to configure TX queues net/mana: implement memory registration

Quoted 9 lines

net/mana: implement the hardware layer operations net/mana: add function to start/stop TX queues net/mana: add function to start/stop RX queues net/mana: add function to receive packets net/mana: add function to send packets net/mana: add function to start/stop device net/mana: add function to report queue stats net/mana: add function to support RX interrupts

Quoted 3 lines

Can you please send new versions of the patches as reply to previous versions, so all versions can be in same thread, using git send-email '--in- reply-to' argument?

Sure, I will send soon.

Quoted 10 lines

More details in the contribution guide:
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoc.
dpdk.org%2Fguides%2Fcontributing%2Fpatches.html%23sending- patches&amp;data=05%7C01%7Clongli%40microsoft.com%7C8cd6ffba9b554 4435e8308da900846a8%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7 C637980662484490031%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C% 7C&amp;sdata=YTEWfVRjiobdQPQDCGoMuLW4N5NISl7VZYKhf6mvSxQ%3D &amp;reserved=0