X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fnet%2Focteontx%2Focteontx_ethdev.c;h=00686ea26a1c8782c27462403f417cfa50cf5594;hb=67fc3ff97c39fd005f2a4ee5f5c7f06208871baa;hp=71843c63a140c5e58438cddf234fac7c552b41cb;hpb=323e7b667f18376c60351282950b28d4d0cc6165;p=dpdk.git diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c index 71843c63a1..00686ea26a 100644 --- a/drivers/net/octeontx/octeontx_ethdev.c +++ b/drivers/net/octeontx/octeontx_ethdev.c @@ -142,7 +142,8 @@ octeontx_port_open(struct octeontx_nic *nic) nic->mcast_mode = bgx_port_conf.mcast_mode; nic->speed = bgx_port_conf.mode; - memcpy(&nic->mac_addr[0], &bgx_port_conf.macaddr[0], ETHER_ADDR_LEN); + memcpy(&nic->mac_addr[0], &bgx_port_conf.macaddr[0], + RTE_ETHER_ADDR_LEN); octeontx_log_dbg("port opened %d", nic->port_id); return res; @@ -173,7 +174,7 @@ octeontx_port_stop(struct octeontx_nic *nic) return octeontx_bgx_port_stop(nic->port_id); } -static void +static int octeontx_port_promisc_set(struct octeontx_nic *nic, int en) { struct rte_eth_dev *dev; @@ -184,15 +185,19 @@ octeontx_port_promisc_set(struct octeontx_nic *nic, int en) dev = nic->dev; res = octeontx_bgx_port_promisc_set(nic->port_id, en); - if (res < 0) + if (res < 0) { octeontx_log_err("failed to set promiscuous mode %d", nic->port_id); + return res; + } /* Set proper flag for the mode */ dev->data->promiscuous = (en != 0) ? 1 : 0; octeontx_log_dbg("port %d : promiscuous mode %s", nic->port_id, en ? "set" : "unset"); + + return 0; } static int @@ -223,12 +228,12 @@ octeontx_port_stats(struct octeontx_nic *nic, struct rte_eth_stats *stats) return 0; } -static void +static int octeontx_port_stats_clr(struct octeontx_nic *nic) { PMD_INIT_FUNC_TRACE(); - octeontx_bgx_port_stats_clr(nic->port_id); + return octeontx_bgx_port_stats_clr(nic->port_id); } static inline void @@ -443,22 +448,22 @@ octeontx_dev_stop(struct rte_eth_dev *dev) } } -static void +static int octeontx_dev_promisc_enable(struct rte_eth_dev *dev) { struct octeontx_nic *nic = octeontx_pmd_priv(dev); PMD_INIT_FUNC_TRACE(); - octeontx_port_promisc_set(nic, 1); + return octeontx_port_promisc_set(nic, 1); } -static void +static int octeontx_dev_promisc_disable(struct rte_eth_dev *dev) { struct octeontx_nic *nic = octeontx_pmd_priv(dev); PMD_INIT_FUNC_TRACE(); - octeontx_port_promisc_set(nic, 0); + return octeontx_port_promisc_set(nic, 0); } static int @@ -544,18 +549,18 @@ octeontx_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) return octeontx_port_stats(nic, stats); } -static void +static int octeontx_dev_stats_reset(struct rte_eth_dev *dev) { struct octeontx_nic *nic = octeontx_pmd_priv(dev); PMD_INIT_FUNC_TRACE(); - octeontx_port_stats_clr(nic); + return octeontx_port_stats_clr(nic); } static int octeontx_dev_default_mac_addr_set(struct rte_eth_dev *dev, - struct ether_addr *addr) + struct rte_ether_addr *addr) { struct octeontx_nic *nic = octeontx_pmd_priv(dev); int ret; @@ -568,7 +573,7 @@ octeontx_dev_default_mac_addr_set(struct rte_eth_dev *dev, return ret; } -static void +static int octeontx_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) { @@ -599,6 +604,8 @@ octeontx_dev_info(struct rte_eth_dev *dev, dev_info->rx_offload_capa = OCTEONTX_RX_OFFLOADS; dev_info->tx_offload_capa = OCTEONTX_TX_OFFLOADS; + + return 0; } static void @@ -844,10 +851,11 @@ octeontx_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx, pktbuf_conf.mmask.f_cache_mode = 1; pktbuf_conf.wqe_skip = OCTTX_PACKET_WQE_SKIP; - pktbuf_conf.first_skip = OCTTX_PACKET_FIRST_SKIP; + pktbuf_conf.first_skip = OCTTX_PACKET_FIRST_SKIP(mb_pool); pktbuf_conf.later_skip = OCTTX_PACKET_LATER_SKIP; pktbuf_conf.mbuff_size = (mb_pool->elt_size - RTE_PKTMBUF_HEADROOM - + rte_pktmbuf_priv_size(mb_pool) - sizeof(struct rte_mbuf)); pktbuf_conf.cache_mode = PKI_OPC_MODE_STF2_STT; @@ -1015,12 +1023,22 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev, return 0; } + /* Reserve an ethdev entry */ + eth_dev = rte_eth_dev_allocate(octtx_name); + if (eth_dev == NULL) { + octeontx_log_err("failed to allocate rte_eth_dev"); + res = -ENOMEM; + goto err; + } + data = eth_dev->data; + nic = rte_zmalloc_socket(octtx_name, sizeof(*nic), 0, socket_id); if (nic == NULL) { octeontx_log_err("failed to allocate nic structure"); res = -ENOMEM; goto err; } + data->dev_private = nic; nic->port_id = port; nic->evdev = evdev; @@ -1037,21 +1055,11 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev, goto err; } - /* Reserve an ethdev entry */ - eth_dev = rte_eth_dev_allocate(octtx_name); - if (eth_dev == NULL) { - octeontx_log_err("failed to allocate rte_eth_dev"); - res = -ENOMEM; - goto err; - } - eth_dev->device = &dev->device; eth_dev->intr_handle = NULL; eth_dev->data->kdrv = RTE_KDRV_NONE; eth_dev->data->numa_node = dev->device.numa_node; - data = eth_dev->data; - data->dev_private = nic; data->port_id = eth_dev->data->port_id; nic->ev_queues = 1; @@ -1063,7 +1071,7 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev, data->all_multicast = 0; data->scattered_rx = 0; - data->mac_addrs = rte_zmalloc_socket(octtx_name, ETHER_ADDR_LEN, 0, + data->mac_addrs = rte_zmalloc_socket(octtx_name, RTE_ETHER_ADDR_LEN, 0, socket_id); if (data->mac_addrs == NULL) { octeontx_log_err("failed to allocate memory for mac_addrs"); @@ -1084,7 +1092,7 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev, } /* Update port_id mac to eth_dev */ - memcpy(data->mac_addrs, nic->mac_addr, ETHER_ADDR_LEN); + memcpy(data->mac_addrs, nic->mac_addr, RTE_ETHER_ADDR_LEN); PMD_INIT_LOG(DEBUG, "ethdev info: "); PMD_INIT_LOG(DEBUG, "port %d, port_ena %d ochan %d num_ochan %d tx_q %d", @@ -1103,12 +1111,7 @@ err: if (nic) octeontx_port_close(nic); - if (eth_dev != NULL) { - rte_free(eth_dev->data->mac_addrs); - rte_free(data); - rte_free(nic); - rte_eth_dev_release_port(eth_dev); - } + rte_eth_dev_release_port(eth_dev); return res; } @@ -1133,16 +1136,22 @@ octeontx_remove(struct rte_vdev_device *dev) if (eth_dev == NULL) return -ENODEV; + if (rte_eal_process_type() != RTE_PROC_PRIMARY) { + rte_eth_dev_release_port(eth_dev); + continue; + } + nic = octeontx_pmd_priv(eth_dev); rte_event_dev_stop(nic->evdev); PMD_INIT_LOG(INFO, "Closing octeontx device %s", octtx_name); - rte_free(eth_dev->data->mac_addrs); - rte_free(eth_dev->data->dev_private); rte_eth_dev_release_port(eth_dev); rte_event_dev_close(nic->evdev); } + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + /* Free FC resource */ octeontx_pko_fc_free(); @@ -1172,7 +1181,7 @@ octeontx_probe(struct rte_vdev_device *dev) strlen(rte_vdev_device_args(dev)) == 0) { eth_dev = rte_eth_dev_attach_secondary(dev_name); if (!eth_dev) { - RTE_LOG(ERR, PMD, "Failed to probe %s\n", dev_name); + PMD_INIT_LOG(ERR, "Failed to probe %s", dev_name); return -1; } /* TODO: request info from primary to set up Rx and Tx */ @@ -1236,15 +1245,8 @@ octeontx_probe(struct rte_vdev_device *dev) res = -EINVAL; goto parse_error; } - if (pnum > qnum) { - /* - * We don't poll on event ports - * that do not have any queues assigned. - */ - pnum = qnum; - PMD_INIT_LOG(INFO, - "reducing number of active event ports to %d", pnum); - } + + /* Enable all queues available */ for (i = 0; i < qnum; i++) { res = rte_event_queue_setup(evdev, i, NULL); if (res < 0) { @@ -1254,6 +1256,7 @@ octeontx_probe(struct rte_vdev_device *dev) } } + /* Enable all ports available */ for (i = 0; i < pnum; i++) { res = rte_event_port_setup(evdev, i, NULL); if (res < 0) { @@ -1262,6 +1265,14 @@ octeontx_probe(struct rte_vdev_device *dev) i, res); goto parse_error; } + } + + /* + * Do 1:1 links for ports & queues. All queues would be mapped to + * one port. If there are more ports than queues, then some ports + * won't be linked to any queue. + */ + for (i = 0; i < qnum; i++) { /* Link one queue to one event port */ qlist = i; res = rte_event_port_link(evdev, i, &qlist, NULL, 1);