X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Focteontx%2Focteontx_ethdev.c;h=04120f502ece655c8de4ff24befc430e387e06bb;hb=c121f00836ca5e233ffeb9eea40d547fb830186e;hp=90dd249a6b84d6a94fdc287c0516c4500503b756;hpb=2b4ab4223d5e9c94f5a556c4d3222f372b3f7453;p=dpdk.git diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c index 90dd249a6b..04120f502e 100644 --- a/drivers/net/octeontx/octeontx_ethdev.c +++ b/drivers/net/octeontx/octeontx_ethdev.c @@ -262,6 +262,8 @@ 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(); @@ -283,34 +285,38 @@ octeontx_dev_configure(struct rte_eth_dev *dev) return -EINVAL; } - if (!rxmode->hw_strip_crc) { + configured_offloads = rxmode->offloads; + + if (!(configured_offloads & DEV_RX_OFFLOAD_CRC_STRIP)) { PMD_INIT_LOG(NOTICE, "can't disable hw crc strip"); - rxmode->hw_strip_crc = 1; + configured_offloads |= DEV_RX_OFFLOAD_CRC_STRIP; } - if (rxmode->hw_ip_checksum) { - PMD_INIT_LOG(NOTICE, "rxcksum not supported"); - rxmode->hw_ip_checksum = 0; - } + unsupported_offloads = configured_offloads & ~OCTEONTX_RX_OFFLOADS; - if (rxmode->split_hdr_size) { - octeontx_log_err("rxmode does not support split header"); - return -EINVAL; + 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; } - if (rxmode->hw_vlan_filter) { - octeontx_log_err("VLAN filter not supported"); - return -EINVAL; - } + configured_offloads = txmode->offloads; - if (rxmode->hw_vlan_extend) { - octeontx_log_err("VLAN extended not supported"); - return -EINVAL; + if (!(configured_offloads & DEV_TX_OFFLOAD_MT_LOCKFREE)) { + PMD_INIT_LOG(NOTICE, "cant disable lockfree tx"); + configured_offloads |= DEV_TX_OFFLOAD_MT_LOCKFREE; } - if (rxmode->enable_lro) { - octeontx_log_err("LRO not supported"); - return -EINVAL; + 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; } if (conf->link_speeds & ETH_LINK_SPEED_FIXED) { @@ -518,7 +524,6 @@ octeontx_dev_link_update(struct rte_eth_dev *dev, struct rte_eth_link link; int res; - res = 0; PMD_INIT_FUNC_TRACE(); res = octeontx_port_link_status(nic); @@ -552,6 +557,7 @@ octeontx_dev_link_update(struct rte_eth_dev *dev, case OCTEONTX_LINK_SPEED_RESERVE1: case OCTEONTX_LINK_SPEED_RESERVE2: default: + link.link_speed = ETH_SPEED_NUM_NONE; octeontx_log_err("incorrect link speed %d", nic->speed); break; } @@ -580,7 +586,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) { @@ -591,6 +597,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 @@ -605,17 +613,16 @@ octeontx_dev_info(struct rte_eth_dev *dev, ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G | ETH_LINK_SPEED_40G; - dev_info->driver_name = RTE_STR(rte_octeontx_pmd); dev_info->max_mac_addrs = 1; dev_info->max_rx_pktlen = PKI_MAX_PKTLEN; dev_info->max_rx_queues = 1; dev_info->max_tx_queues = PKO_MAX_NUM_DQ; dev_info->min_rx_bufsize = 0; - dev_info->pci_dev = NULL; dev_info->default_rxconf = (struct rte_eth_rxconf) { .rx_free_thresh = 0, .rx_drop_en = 0, + .offloads = OCTEONTX_RX_OFFLOADS, }; dev_info->default_txconf = (struct rte_eth_txconf) { @@ -626,7 +633,8 @@ octeontx_dev_info(struct rte_eth_dev *dev, ETH_TXQ_FLAGS_NOXSUMS, }; - dev_info->tx_offload_capa = DEV_TX_OFFLOAD_MT_LOCKFREE; + dev_info->rx_offload_capa = OCTEONTX_RX_OFFLOADS; + dev_info->tx_offload_capa = OCTEONTX_TX_OFFLOADS; } static void @@ -736,10 +744,11 @@ octeontx_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx, 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); - RTE_SET_USED(tx_conf); dq_num = (nic->port_id * PKO_VF_NUM_DQ) + qidx; @@ -757,6 +766,22 @@ 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); @@ -812,6 +837,8 @@ 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); @@ -834,6 +861,22 @@ 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"); @@ -1025,7 +1068,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(); @@ -1041,13 +1084,6 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev, 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"); @@ -1083,11 +1119,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; @@ -1106,7 +1140,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 */ @@ -1174,7 +1207,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); } @@ -1196,12 +1228,26 @@ 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; + return 0; + } + res = octeontx_parse_vdev_init_params(&init_params, dev); if (res < 0) return -EINVAL;