Skip to content

Commit 1f76c35

Browse files
committed
drivers/nfb: native support for DMA controller
Introduce the native driver for the DMA Medusa controller. It doesn't uses NDP/libnfb with syscall in fast path, so it has better data throughput and better utilizes system resources.
1 parent 8ad7f51 commit 1f76c35

File tree

8 files changed

+850
-80
lines changed

8 files changed

+850
-80
lines changed

drivers/net/nfb/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ sources = files(
2020
'nfb_rxmode.c',
2121
'nfb_stats.c',
2222
'nfb_tx.c',
23+
'nfb_queue_ndp.c',
2324
'mdio.c',
2425
)

drivers/net/nfb/nfb.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,14 @@
3939

4040
#define RTE_NFB_DRIVER_NAME net_nfb
4141

42+
#define NFB_QUEUE_DRIVER_NDP_SHARED 1
43+
#define NFB_QUEUE_DRIVER_NATIVE 2
44+
4245
/* Device arguments */
4346
#define NFB_ARG_RXHDR_DYNFIELD "rxhdr_dynfield"
47+
#define NFB_ARG_QUEUE_DRIVER "queue_driver"
4448

45-
static const char * const VALID_KEYS[] = {NFB_ARG_RXHDR_DYNFIELD, NULL};
49+
static const char * const VALID_KEYS[] = {NFB_ARG_RXHDR_DYNFIELD, NFB_ARG_QUEUE_DRIVER, NULL};
4650

4751
struct eth_node{
4852
struct mdio_if_info if_info;
@@ -59,6 +63,8 @@ struct pmd_internals {
5963
int *queue_map_tx;
6064

6165
struct nfb_device *nfb;
66+
int nfb_id;
67+
int flags;
6268
};
6369

6470
struct pmd_priv {

drivers/net/nfb/nfb_ethdev.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,8 @@ nfb_eth_dev_init(struct rte_eth_dev *dev, void *init_data)
749749
struct rte_ether_addr eth_addr_init;
750750
struct rte_kvargs *kvlist;
751751

752+
const char *arg_val;
753+
752754
internals = (struct pmd_internals *) rte_zmalloc_socket("nfb_internals",
753755
sizeof(struct pmd_internals), RTE_CACHE_LINE_SIZE,
754756
dev->device->numa_node);
@@ -758,6 +760,9 @@ nfb_eth_dev_init(struct rte_eth_dev *dev, void *init_data)
758760
}
759761

760762
dev->process_private = internals;
763+
internals->flags = 0;
764+
765+
internals->flags = NFB_QUEUE_DRIVER_NDP_SHARED;
761766

762767
/* Check validity of device args */
763768
if (dev->device->devargs != NULL &&
@@ -778,9 +783,17 @@ nfb_eth_dev_init(struct rte_eth_dev *dev, void *init_data)
778783
}
779784
}
780785

786+
if ((arg_val = rte_kvargs_get(kvlist, NFB_ARG_QUEUE_DRIVER))) {
787+
if (strcmp(arg_val, "native") == 0) {
788+
internals->flags &= ~NFB_QUEUE_DRIVER_NDP_SHARED;
789+
}
790+
}
791+
781792
rte_kvargs_free(kvlist);
782793
}
783794

795+
internals->nfb_id = params->nfb_id;
796+
784797
/* Open device handle */
785798
internals->nfb = nfb_open(params->path);
786799
if (internals->nfb == NULL) {
@@ -794,8 +807,17 @@ nfb_eth_dev_init(struct rte_eth_dev *dev, void *init_data)
794807
nfb_nc_eth_init(internals, params);
795808

796809
/* Set rx, tx burst functions */
797-
dev->rx_pkt_burst = nfb_eth_ndp_rx;
798-
dev->tx_pkt_burst = nfb_eth_ndp_tx;
810+
if (internals->flags & NFB_QUEUE_DRIVER_NDP_SHARED) {
811+
dev->rx_pkt_burst = nfb_eth_ndp_rx;
812+
dev->tx_pkt_burst = nfb_eth_ndp_tx;
813+
//RTE_LOG(ERR, PMD, "NFB: Using NDP driver for rx/tx\n");
814+
printf("NFB: Using NDP driver for rx/tx\n");
815+
} else {
816+
dev->rx_pkt_burst = nfb_ndp_queue_rx;
817+
dev->tx_pkt_burst = nfb_ndp_queue_tx;
818+
//RTE_LOG(ERR, PMD, "NFB: Using Native driver for rx/tx\n");
819+
printf("NFB: Using Native driver for rx/tx\n");
820+
}
799821

800822
/* Get number of available DMA RX and TX queues */
801823
priv->max_rx_queues = ifc->rxq_cnt;
@@ -1020,4 +1042,5 @@ RTE_PMD_REGISTER_PCI(RTE_NFB_DRIVER_NAME, nfb_eth_driver);
10201042
RTE_PMD_REGISTER_PCI_TABLE(RTE_NFB_DRIVER_NAME, nfb_pci_id_table);
10211043
RTE_PMD_REGISTER_KMOD_DEP(RTE_NFB_DRIVER_NAME, "* nfb");
10221044
RTE_PMD_REGISTER_PARAM_STRING(RTE_NFB_DRIVER_NAME,
1023-
NFB_ARG_RXHDR_DYNFIELD"=<0|1>");
1045+
NFB_ARG_RXHDR_DYNFIELD"=<0|1> "
1046+
NFB_ARG_QUEUE_DRIVER"=<ndp|native>");

0 commit comments

Comments
 (0)