From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 8511C8064 for ; Fri, 12 Dec 2014 10:14:54 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 12 Dec 2014 01:14:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,561,1413270000"; d="scan'208";a="646557000" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 12 Dec 2014 01:14:47 -0800 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id sBC9ElFA029128; Fri, 12 Dec 2014 09:14:47 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id sBC9ElYR004767; Fri, 12 Dec 2014 09:14:47 GMT Received: (from mkjastrx@localhost) by sivswdev01.ir.intel.com with id sBC9Ek50004763; Fri, 12 Dec 2014 09:14:46 GMT From: Michal Jastrzebski To: dev@dpdk.org Date: Fri, 12 Dec 2014 09:14:41 +0000 Message-Id: <1418375682-4703-3-git-send-email-michalx.k.jastrzebski@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1418375682-4703-1-git-send-email-michalx.k.jastrzebski@intel.com> References: <1418375682-4703-1-git-send-email-michalx.k.jastrzebski@intel.com> Cc: tomaszx.kulasek@intel.com Subject: [dpdk-dev] [PATCH 2/3] PMD ring MAC management, fix initialization, link up/down X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Dec 2014 09:14:55 -0000 * add MAC management per device * fix initialization procedure * add link up/down functions Signed-off-by: Pawel Wodkowski Signed-off-by: Tomasz Kulasek --- lib/librte_pmd_ring/rte_eth_ring.c | 62 +++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/lib/librte_pmd_ring/rte_eth_ring.c b/lib/librte_pmd_ring/rte_eth_ring.c index 4f1b6ed..b6047cc 100644 --- a/lib/librte_pmd_ring/rte_eth_ring.c +++ b/lib/librte_pmd_ring/rte_eth_ring.c @@ -44,6 +44,8 @@ #define ETH_RING_ACTION_CREATE "CREATE" #define ETH_RING_ACTION_ATTACH "ATTACH" +static const char *ring_ethdev_driver_name = "Ring PMD"; + static const char *valid_arguments[] = { ETH_RING_NUMA_NODE_ACTION_ARG, NULL @@ -62,10 +64,11 @@ struct pmd_internals { struct ring_queue rx_ring_queues[RTE_PMD_RING_MAX_RX_RINGS]; struct ring_queue tx_ring_queues[RTE_PMD_RING_MAX_TX_RINGS]; + + struct ether_addr address; }; -static struct ether_addr eth_addr = { .addr_bytes = {0} }; static const char *drivername = "Rings PMD"; static struct rte_eth_link pmd_link = { .link_speed = 10000, @@ -121,6 +124,20 @@ eth_dev_stop(struct rte_eth_dev *dev) } static int +eth_dev_set_link_down(struct rte_eth_dev *dev) +{ + dev->data->dev_link.link_status = 0; + return 0; +} + +static int +eth_dev_set_link_up(struct rte_eth_dev *dev) +{ + dev->data->dev_link.link_status = 1; + return 0; +} + +static int eth_rx_queue_setup(struct rte_eth_dev *dev,uint16_t rx_queue_id, uint16_t nb_rx_desc __rte_unused, unsigned int socket_id __rte_unused, @@ -199,6 +216,20 @@ eth_stats_reset(struct rte_eth_dev *dev) } static void +eth_mac_addr_remove(struct rte_eth_dev *dev __rte_unused, + uint32_t index __rte_unused) +{ +} + +static void +eth_mac_addr_add(struct rte_eth_dev *dev __rte_unused, + struct ether_addr *mac_addr __rte_unused, + uint32_t index __rte_unused, + uint32_t vmdq __rte_unused) +{ +} + +static void eth_queue_release(void *q __rte_unused) { ; } static int eth_link_update(struct rte_eth_dev *dev __rte_unused, @@ -207,6 +238,8 @@ eth_link_update(struct rte_eth_dev *dev __rte_unused, static struct eth_dev_ops ops = { .dev_start = eth_dev_start, .dev_stop = eth_dev_stop, + .dev_set_link_up = eth_dev_set_link_up, + .dev_set_link_down = eth_dev_set_link_down, .dev_configure = eth_dev_configure, .dev_infos_get = eth_dev_info, .rx_queue_setup = eth_rx_queue_setup, @@ -216,6 +249,8 @@ static struct eth_dev_ops ops = { .link_update = eth_link_update, .stats_get = eth_stats_get, .stats_reset = eth_stats_reset, + .mac_addr_remove = eth_mac_addr_remove, + .mac_addr_add = eth_mac_addr_add, }; int @@ -229,6 +264,9 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[], struct rte_pci_device *pci_dev = NULL; struct pmd_internals *internals = NULL; struct rte_eth_dev *eth_dev = NULL; + struct eth_driver *eth_drv = NULL; + struct rte_pci_id *id_table = NULL; + unsigned i; /* do some parameter checking */ @@ -251,6 +289,10 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[], if (pci_dev == NULL) goto error; + id_table = rte_zmalloc_socket(name, sizeof(*id_table), 0, numa_node); + if (id_table == NULL) + goto error; + internals = rte_zmalloc_socket(name, sizeof(*internals), 0, numa_node); if (internals == NULL) goto error; @@ -260,6 +302,10 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[], if (eth_dev == NULL) goto error; + eth_drv = rte_zmalloc_socket(name, sizeof(*eth_drv), 0, numa_node); + if (eth_drv == NULL) + goto error; + /* now put it all together * - store queue data in internals, * - store numa_node info in pci_driver @@ -278,18 +324,24 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[], internals->tx_ring_queues[i].rng = tx_queues[i]; } + eth_drv->pci_drv.name = ring_ethdev_driver_name; + eth_drv->pci_drv.id_table = id_table; + pci_dev->numa_node = numa_node; + pci_dev->driver = ð_drv->pci_drv; data->dev_private = internals; data->port_id = eth_dev->data->port_id; data->nb_rx_queues = (uint16_t)nb_rx_queues; data->nb_tx_queues = (uint16_t)nb_tx_queues; data->dev_link = pmd_link; - data->mac_addrs = ð_addr; + data->mac_addrs = &internals->address; - eth_dev ->data = data; - eth_dev ->dev_ops = &ops; - eth_dev ->pci_dev = pci_dev; + eth_dev->data = data; + eth_dev->driver = eth_drv; + eth_dev->dev_ops = &ops; + eth_dev->pci_dev = pci_dev; + TAILQ_INIT(&(eth_dev->callbacks)); /* finally assign rx and tx ops */ eth_dev->rx_pkt_burst = eth_ring_rx; -- 1.7.9.5