X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Focteontx%2Focteontx_ethdev.c;h=1eb453b21249a25b8792f8835b638e60b17be4bc;hb=44cbeffe77651239cb4d425c61b9ee1cfde27152;hp=f829e0ca985cc0162fbf8c59a0814d813209dbc6;hpb=cd8c7c7ce241d2ea7c059a9df07caa9411ef19ed;p=dpdk.git diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c index f829e0ca98..1eb453b212 100644 --- a/drivers/net/octeontx/octeontx_ethdev.c +++ b/drivers/net/octeontx/octeontx_ethdev.c @@ -262,8 +262,6 @@ octeontx_dev_configure(struct rte_eth_dev *dev) struct rte_eth_rxmode *rxmode = &conf->rxmode; struct rte_eth_txmode *txmode = &conf->txmode; struct octeontx_nic *nic = octeontx_pmd_priv(dev); - uint64_t configured_offloads; - uint64_t unsupported_offloads; int ret; PMD_INIT_FUNC_TRACE(); @@ -285,38 +283,14 @@ octeontx_dev_configure(struct rte_eth_dev *dev) return -EINVAL; } - configured_offloads = rxmode->offloads; - - if (!(configured_offloads & DEV_RX_OFFLOAD_CRC_STRIP)) { + if (!(rxmode->offloads & DEV_RX_OFFLOAD_CRC_STRIP)) { PMD_INIT_LOG(NOTICE, "can't disable hw crc strip"); - configured_offloads |= DEV_RX_OFFLOAD_CRC_STRIP; - } - - unsupported_offloads = configured_offloads & ~OCTEONTX_RX_OFFLOADS; - - if (unsupported_offloads) { - PMD_INIT_LOG(ERR, "Rx offloads 0x%" PRIx64 " are not supported. " - "Requested 0x%" PRIx64 " supported 0x%" PRIx64 "\n", - unsupported_offloads, configured_offloads, - (uint64_t)OCTEONTX_RX_OFFLOADS); - return -ENOTSUP; + rxmode->offloads |= DEV_RX_OFFLOAD_CRC_STRIP; } - configured_offloads = txmode->offloads; - - if (!(configured_offloads & DEV_TX_OFFLOAD_MT_LOCKFREE)) { + if (!(txmode->offloads & DEV_TX_OFFLOAD_MT_LOCKFREE)) { PMD_INIT_LOG(NOTICE, "cant disable lockfree tx"); - configured_offloads |= DEV_TX_OFFLOAD_MT_LOCKFREE; - } - - unsupported_offloads = configured_offloads & ~OCTEONTX_TX_OFFLOADS; - - if (unsupported_offloads) { - PMD_INIT_LOG(ERR, "Tx offloads 0x%" PRIx64 " are not supported." - "Requested 0x%" PRIx64 " supported 0x%" PRIx64 ".\n", - unsupported_offloads, configured_offloads, - (uint64_t)OCTEONTX_TX_OFFLOADS); - return -ENOTSUP; + txmode->offloads |= DEV_TX_OFFLOAD_MT_LOCKFREE; } if (conf->link_speeds & ETH_LINK_SPEED_FIXED) { @@ -586,7 +560,7 @@ octeontx_dev_stats_reset(struct rte_eth_dev *dev) octeontx_port_stats_clr(nic); } -static void +static int octeontx_dev_default_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *addr) { @@ -597,6 +571,8 @@ octeontx_dev_default_mac_addr_set(struct rte_eth_dev *dev, if (ret != 0) octeontx_log_err("failed to set MAC address on port %d", nic->port_id); + + return ret; } static void @@ -625,10 +601,7 @@ octeontx_dev_info(struct rte_eth_dev *dev, dev_info->default_txconf = (struct rte_eth_txconf) { .tx_free_thresh = 0, - .txq_flags = - ETH_TXQ_FLAGS_NOMULTSEGS | - ETH_TXQ_FLAGS_NOOFFLOADS | - ETH_TXQ_FLAGS_NOXSUMS, + .offloads = OCTEONTX_TX_OFFLOADS, }; dev_info->rx_offload_capa = OCTEONTX_RX_OFFLOADS; @@ -736,14 +709,12 @@ octeontx_dev_tx_queue_release(void *tx_queue) static int octeontx_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx, uint16_t nb_desc, unsigned int socket_id, - const struct rte_eth_txconf *tx_conf) + const struct rte_eth_txconf *tx_conf __rte_unused) { struct octeontx_nic *nic = octeontx_pmd_priv(dev); struct octeontx_txq *txq = NULL; uint16_t dq_num; int res = 0; - uint64_t configured_offloads; - uint64_t unsupported_offloads; RTE_SET_USED(nb_desc); RTE_SET_USED(socket_id); @@ -764,22 +735,6 @@ octeontx_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx, dev->data->tx_queues[qidx] = NULL; } - configured_offloads = tx_conf->offloads; - - if (!(configured_offloads & DEV_TX_OFFLOAD_MT_LOCKFREE)) { - PMD_INIT_LOG(NOTICE, "cant disable lockfree tx"); - configured_offloads |= DEV_TX_OFFLOAD_MT_LOCKFREE; - } - - unsupported_offloads = configured_offloads & ~OCTEONTX_TX_OFFLOADS; - if (unsupported_offloads) { - PMD_INIT_LOG(ERR, "Tx offloads 0x%" PRIx64 " are not supported." - "Requested 0x%" PRIx64 " supported 0x%" PRIx64 ".\n", - unsupported_offloads, configured_offloads, - (uint64_t)OCTEONTX_TX_OFFLOADS); - return -ENOTSUP; - } - /* Allocating tx queue data structure */ txq = rte_zmalloc_socket("ethdev TX queue", sizeof(struct octeontx_txq), RTE_CACHE_LINE_SIZE, nic->node); @@ -835,8 +790,6 @@ octeontx_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx, uint8_t gaura; unsigned int ev_queues = (nic->ev_queues * nic->port_id) + qidx; unsigned int ev_ports = (nic->ev_ports * nic->port_id) + qidx; - uint64_t configured_offloads; - uint64_t unsupported_offloads; RTE_SET_USED(nb_desc); @@ -859,22 +812,6 @@ octeontx_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx, port = nic->port_id; - configured_offloads = rx_conf->offloads; - - if (!(configured_offloads & DEV_RX_OFFLOAD_CRC_STRIP)) { - PMD_INIT_LOG(NOTICE, "can't disable hw crc strip"); - configured_offloads |= DEV_RX_OFFLOAD_CRC_STRIP; - } - - unsupported_offloads = configured_offloads & ~OCTEONTX_RX_OFFLOADS; - - if (unsupported_offloads) { - PMD_INIT_LOG(ERR, "Rx offloads 0x%" PRIx64 " are not supported. " - "Requested 0x%" PRIx64 " supported 0x%" PRIx64 "\n", - unsupported_offloads, configured_offloads, - (uint64_t)OCTEONTX_RX_OFFLOADS); - return -ENOTSUP; - } /* Rx deferred start is not supported */ if (rx_conf->rx_deferred_start) { octeontx_log_err("rx deferred start not supported"); @@ -1066,7 +1003,7 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev, char octtx_name[OCTEONTX_MAX_NAME_LEN]; struct octeontx_nic *nic = NULL; struct rte_eth_dev *eth_dev = NULL; - struct rte_eth_dev_data *data = NULL; + struct rte_eth_dev_data *data; const char *name = rte_vdev_device_name(dev); PMD_INIT_FUNC_TRACE(); @@ -1079,16 +1016,10 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev, eth_dev->tx_pkt_burst = octeontx_xmit_pkts; eth_dev->rx_pkt_burst = octeontx_recv_pkts; + rte_eth_dev_probing_finish(eth_dev); return 0; } - data = rte_zmalloc_socket(octtx_name, sizeof(*data), 0, socket_id); - if (data == NULL) { - octeontx_log_err("failed to allocate devdata"); - res = -ENOMEM; - goto err; - } - nic = rte_zmalloc_socket(octtx_name, sizeof(*nic), 0, socket_id); if (nic == NULL) { octeontx_log_err("failed to allocate nic structure"); @@ -1124,11 +1055,9 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev, eth_dev->data->kdrv = RTE_KDRV_NONE; eth_dev->data->numa_node = dev->device.numa_node; - rte_memcpy(data, (eth_dev)->data, sizeof(*data)); + data = eth_dev->data; data->dev_private = nic; - data->port_id = eth_dev->data->port_id; - snprintf(data->name, sizeof(data->name), "%s", eth_dev->data->name); nic->ev_queues = 1; nic->ev_ports = 1; @@ -1147,7 +1076,6 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev, goto err; } - eth_dev->data = data; eth_dev->dev_ops = &octeontx_dev_ops; /* Finally save ethdev pointer to the NIC structure */ @@ -1173,6 +1101,7 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev, rte_octeontx_pchan_map[(nic->base_ochan >> 8) & 0x7] [(nic->base_ochan >> 4) & 0xF] = data->port_id; + rte_eth_dev_probing_finish(eth_dev); return data->port_id; err: @@ -1215,7 +1144,6 @@ octeontx_remove(struct rte_vdev_device *dev) rte_free(eth_dev->data->mac_addrs); rte_free(eth_dev->data->dev_private); - rte_free(eth_dev->data); rte_eth_dev_release_port(eth_dev); rte_event_dev_close(nic->evdev); } @@ -1237,12 +1165,27 @@ octeontx_probe(struct rte_vdev_device *dev) struct rte_event_dev_config dev_conf; const char *eventdev_name = "event_octeontx"; struct rte_event_dev_info info; + struct rte_eth_dev *eth_dev; struct octeontx_vdev_init_params init_params = { OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT }; dev_name = rte_vdev_device_name(dev); + + if (rte_eal_process_type() == RTE_PROC_SECONDARY && + 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); + return -1; + } + /* TODO: request info from primary to set up Rx and Tx */ + eth_dev->dev_ops = &octeontx_dev_ops; + rte_eth_dev_probing_finish(eth_dev); + return 0; + } + res = octeontx_parse_vdev_init_params(&init_params, dev); if (res < 0) return -EINVAL;