X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=VNFs%2FDPPD-PROX%2Fprox_port_cfg.c;h=043e755b84cf376891dda51f1061387233971394;hb=0d8616af8418480595a2c53e1dc7c3b809962a28;hp=fc4971f1e2584c220318039ad3b9ca3afe47a0d6;hpb=c410fc3bd16046ed9b22c228017b6dea9f7c3f33;p=samplevnf.git diff --git a/VNFs/DPPD-PROX/prox_port_cfg.c b/VNFs/DPPD-PROX/prox_port_cfg.c index fc4971f1..043e755b 100644 --- a/VNFs/DPPD-PROX/prox_port_cfg.c +++ b/VNFs/DPPD-PROX/prox_port_cfg.c @@ -311,6 +311,20 @@ uint8_t init_rte_ring_dev(void) static void print_port_capa(struct prox_port_cfg *port_cfg) { + uint8_t port_id; + + port_id = port_cfg - prox_port_cfg; + plog_info("\t*** Initializing port %u ***\n", port_id); + plog_info("\t\tPort name is set to %s\n", port_cfg->name); + plog_info("\t\tPort max RX/TX queue is %u/%u\n", port_cfg->max_rxq, port_cfg->max_txq); + plog_info("\t\tPort driver is %s\n", port_cfg->driver_name); +#if RTE_VERSION >= RTE_VERSION_NUM(16,4,0,0) + plog_info("\t\tSupported speed mask = 0x%x\n", port_cfg->dev_info.speed_capa); +#endif + if (port_cfg->max_link_speed != UINT32_MAX) { + plog_info("\t\tHighest link speed capa = %d Mbps\n", port_cfg->max_link_speed); + } + #if RTE_VERSION >= RTE_VERSION_NUM(18,8,0,1) plog_info("\t\tRX offload capa = 0x%lx = ", port_cfg->dev_info.rx_offload_capa); if (port_cfg->dev_info.rx_offload_capa & DEV_RX_OFFLOAD_VLAN_STRIP) @@ -396,6 +410,48 @@ static void print_port_capa(struct prox_port_cfg *port_cfg) #endif } +static void get_max_link_speed(struct prox_port_cfg *port_cfg) +{ + port_cfg->max_link_speed = UINT32_MAX; + +#if RTE_VERSION >= RTE_VERSION_NUM(16,4,0,0) + // virtio and vmxnet3 reports fake max_link_speed + if (strcmp(port_cfg->short_name, "vmxnet3") && strcmp(port_cfg->short_name, "virtio")) { + // Get link_speed from highest capability from the port + // This will be used by gen and lat for extrapolation purposes + // The negotiated link_speed (as reported by rte_eth_link_get + // or rte_eth_link_get_nowait) might be reported too late + // and might result in wrong exrapolation, and hence should not be used + // for extrapolation purposes + if (port_cfg->dev_info.speed_capa & ETH_LINK_SPEED_100G) + port_cfg->max_link_speed = ETH_SPEED_NUM_100G; + else if (port_cfg->dev_info.speed_capa & ETH_LINK_SPEED_56G) + port_cfg->max_link_speed = ETH_SPEED_NUM_56G; + else if (port_cfg->dev_info.speed_capa & ETH_LINK_SPEED_50G) + port_cfg->max_link_speed = ETH_SPEED_NUM_50G; + else if (port_cfg->dev_info.speed_capa & ETH_LINK_SPEED_40G) + port_cfg->max_link_speed = ETH_SPEED_NUM_40G; + else if (port_cfg->dev_info.speed_capa & ETH_LINK_SPEED_25G) + port_cfg->max_link_speed = ETH_SPEED_NUM_25G; + else if (port_cfg->dev_info.speed_capa & ETH_LINK_SPEED_20G) + port_cfg->max_link_speed = ETH_SPEED_NUM_20G; + else if (port_cfg->dev_info.speed_capa & ETH_LINK_SPEED_10G) + port_cfg->max_link_speed = ETH_SPEED_NUM_10G; + else if (port_cfg->dev_info.speed_capa & ETH_LINK_SPEED_5G) + port_cfg->max_link_speed = ETH_SPEED_NUM_5G; + else if (port_cfg->dev_info.speed_capa & ETH_LINK_SPEED_2_5G) + port_cfg->max_link_speed = ETH_SPEED_NUM_2_5G; + else if (port_cfg->dev_info.speed_capa & ETH_LINK_SPEED_1G) + port_cfg->max_link_speed = ETH_SPEED_NUM_1G; + else if (port_cfg->dev_info.speed_capa & (ETH_LINK_SPEED_100M_HD | ETH_LINK_SPEED_100M)) + port_cfg->max_link_speed = ETH_SPEED_NUM_100M; + else if (port_cfg->dev_info.speed_capa & (ETH_LINK_SPEED_10M_HD | ETH_LINK_SPEED_10M)) + port_cfg->max_link_speed = ETH_SPEED_NUM_10M; + + } +#endif +} + static void init_port(struct prox_port_cfg *port_cfg) { static char dummy_pool_name[] = "0_dummy"; @@ -403,15 +459,9 @@ static void init_port(struct prox_port_cfg *port_cfg) uint8_t port_id; int ret; + get_max_link_speed(port_cfg); + print_port_capa(port_cfg); port_id = port_cfg - prox_port_cfg; - plog_info("\t*** Initializing port %u ***\n", port_id); - plog_info("\t\tPort name is set to %s\n", port_cfg->name); - plog_info("\t\tPort max RX/TX queue is %u/%u\n", port_cfg->max_rxq, port_cfg->max_txq); - plog_info("\t\tPort driver is %s\n", port_cfg->driver_name); -#if RTE_VERSION >= RTE_VERSION_NUM(16,4,0,0) - plog_info("\t\tSupported speed mask = 0x%x\n", port_cfg->dev_info.speed_capa); -#endif - PROX_PANIC(port_cfg->n_rxq == 0 && port_cfg->n_txq == 0, "\t\t port %u is enabled but no RX or TX queues have been configured", port_id); @@ -420,6 +470,9 @@ static void init_port(struct prox_port_cfg *port_cfg) plog_info("\t\tPort %u had no RX queues, setting to 1\n", port_id); port_cfg->n_rxq = 1; uint32_t mbuf_size = TX_MBUF_SIZE; + if (mbuf_size < port_cfg->min_rx_bufsize + RTE_PKTMBUF_HEADROOM + sizeof(struct rte_mbuf)) + mbuf_size = port_cfg->min_rx_bufsize + RTE_PKTMBUF_HEADROOM + sizeof(struct rte_mbuf); + plog_info("\t\tAllocating dummy memory pool on socket %u with %u elements of size %u\n", port_cfg->socket, port_cfg->n_rxd, mbuf_size); port_cfg->pool[0] = rte_mempool_create(dummy_pool_name, port_cfg->n_rxd, mbuf_size, @@ -449,8 +502,6 @@ static void init_port(struct prox_port_cfg *port_cfg) } } - print_port_capa(port_cfg); - if (port_cfg->n_rxq > 1) { // Enable RSS if multiple receive queues port_cfg->port_conf.rxmode.mq_mode |= ETH_MQ_RX_RSS; @@ -605,6 +656,7 @@ static void init_port(struct prox_port_cfg *port_cfg) port_cfg->link_up = link.link_status; port_cfg->link_speed = link.link_speed; + if (link.link_status) { plog_info("Link Up - speed %'u Mbps - %s\n", link.link_speed,