summaryrefslogtreecommitdiff
path: root/accel-dp/eth_dev.c
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2016-07-09 20:07:17 +0300
committerDmitry Kozlov <xeb@mail.ru>2016-07-09 20:07:17 +0300
commitff364ceb8a6c92c7da630c4bc408e888ac3d9266 (patch)
treeeb3e87b8fbdf2756cfedb4c134a08bc4745af807 /accel-dp/eth_dev.c
parent81df5d567b747b2af12a1c2fa2a330899b22821b (diff)
downloadaccel-ppp-ff364ceb8a6c92c7da630c4bc408e888ac3d9266.tar.gz
accel-ppp-ff364ceb8a6c92c7da630c4bc408e888ac3d9266.zip
removed accel-dp related files
accel-dp will be continued in separated branch
Diffstat (limited to 'accel-dp/eth_dev.c')
-rw-r--r--accel-dp/eth_dev.c118
1 files changed, 0 insertions, 118 deletions
diff --git a/accel-dp/eth_dev.c b/accel-dp/eth_dev.c
deleted file mode 100644
index c99edba..0000000
--- a/accel-dp/eth_dev.c
+++ /dev/null
@@ -1,118 +0,0 @@
-#include <unistd.h>
-
-#include <rte_config.h>
-#include <rte_mbuf.h>
-#include <rte_ethdev.h>
-#include <rte_malloc.h>
-#include <rte_errno.h>
-
-#include "init.h"
-#include "conf_file.h"
-#include "dev.h"
-
-#define TX_RING_SIZE 512
-#define RX_RING_SIZE 512
-
-struct ethdev {
- int port;
-};
-
-static struct ethdev **dev_list;
-
-static void ethdev_xmit(struct rte_mbuf *mbuf, struct net_device *dev)
-{
- struct ethdev *eth_dev = netdev_priv(dev);
-
- mbuf->port = eth_dev->port;
-}
-
-int eth_dev_init(struct rte_mempool *mbuf_pool)
-{
- struct conf_sect *s = conf_get_sect("interface");
- struct conf_opt *opt;
- int i, cnt = rte_eth_dev_count();
- struct rte_eth_dev_info info;
- char busid[64];
- const char *opt1;
- int rxd, txd;
- struct net_device *dev;
- struct ethdev *eth_dev;
- struct ether_addr addr;
- struct rte_eth_link link;
- struct rte_eth_conf conf = {
- .rxmode = {
- .mq_mode = ETH_MQ_RX_NONE,
- .max_rx_pkt_len = ETHER_MAX_LEN + 8,
- },
- .txmode = {
- .mq_mode = ETH_MQ_TX_NONE,
- },
- };
-
- dev_list = rte_malloc(NULL, cnt * sizeof(void *), 0);
-
- for (i = 0; i < cnt; i++) {
- rte_eth_dev_info_get(i, &info);
-
- sprintf(busid, "%04x:%02x:%02x.%i", info.pci_dev->addr.domain, info.pci_dev->addr.bus, info.pci_dev->addr.devid, info.pci_dev->addr.function);
-
- for (opt = s->opt; opt; opt = opt->next) {
- const char *opt_busid = conf_get_subopt(opt, "busid");
- if (!strcmp(opt_busid, busid) || !strcmp(opt_busid, busid + 5))
- break;
- }
-
- opt1 = conf_get_subopt(opt, "txd");
- if (opt1)
- txd = atoi(opt1);
- else
- txd = TX_RING_SIZE;
-
- opt1 = conf_get_subopt(opt, "rxd");
- if (opt1)
- rxd = atoi(opt1);
- else
- rxd = RX_RING_SIZE;
-
- if (rte_eth_dev_configure(i, 1, 1, &conf)) {
- fprintf(stderr, "%s: %s\n", busid, rte_strerror(rte_errno));
- return -1;
- }
-
- if (rte_eth_rx_queue_setup(i, 0, rxd, rte_eth_dev_socket_id(i), NULL, mbuf_pool)) {
- fprintf(stderr, "%s: %s\n", busid, rte_strerror(rte_errno));
- return -1;
- }
-
- if (rte_eth_tx_queue_setup(i, 0, txd, rte_eth_dev_socket_id(i), NULL)) {
- fprintf(stderr, "%s: %s\n", busid, rte_strerror(rte_errno));
- return -1;
- }
-
- if (rte_eth_dev_start(i)) {
- fprintf(stderr, "%s: %s\n", busid, rte_strerror(rte_errno));
- return -1;
- }
-
- rte_eth_link_get_nowait(i, &link);
- if (!link.link_status) {
- sleep(1);
- rte_eth_link_get_nowait(i, &link);
- }
-
- if (!link.link_status)
- printf("%s: link down\n", opt->name);
-
- rte_eth_macaddr_get(i, &addr);
-
- dev = netdev_alloc(opt->name, sizeof(*eth_dev), NULL);
- dev->xmit = ethdev_xmit;
- memcpy(dev->hwaddr, addr.addr_bytes, ETHER_ADDR_LEN);
- eth_dev = netdev_priv(dev);
- eth_dev->port = i;
-
- dev_list[i] = eth_dev;
- }
-
- return 0;
-}