MCPcopy Create free account
hub / github.com/F-Stack/f-stack / virtio_dev_configure

Function virtio_dev_configure

dpdk/drivers/net/virtio/virtio_ethdev.c:2131–2328  ·  view source on GitHub ↗

* Configure virtio device * It returns 0 on success. */

Source from the content-addressed store, hash-verified

2129 * It returns 0 on success.
2130 */
2131static int
2132virtio_dev_configure(struct rte_eth_dev *dev)
2133{
2134 const struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
2135 const struct rte_eth_txmode *txmode = &dev->data->dev_conf.txmode;
2136 struct virtio_hw *hw = dev->data->dev_private;
2137 uint32_t ether_hdr_len = RTE_ETHER_HDR_LEN + VLAN_TAG_LEN +
2138 hw->vtnet_hdr_size;
2139 uint64_t rx_offloads = rxmode->offloads;
2140 uint64_t tx_offloads = txmode->offloads;
2141 uint64_t req_features;
2142 int ret;
2143
2144 PMD_INIT_LOG(DEBUG, "configure");
2145 req_features = VIRTIO_PMD_DEFAULT_GUEST_FEATURES;
2146
2147 if (rxmode->mq_mode != RTE_ETH_MQ_RX_NONE && rxmode->mq_mode != RTE_ETH_MQ_RX_RSS) {
2148 PMD_DRV_LOG(ERR,
2149 "Unsupported Rx multi queue mode %d",
2150 rxmode->mq_mode);
2151 return -EINVAL;
2152 }
2153
2154 if (txmode->mq_mode != RTE_ETH_MQ_TX_NONE) {
2155 PMD_DRV_LOG(ERR,
2156 "Unsupported Tx multi queue mode %d",
2157 txmode->mq_mode);
2158 return -EINVAL;
2159 }
2160
2161 if (dev->data->dev_conf.intr_conf.rxq) {
2162 ret = virtio_init_device(dev, hw->req_guest_features);
2163 if (ret < 0)
2164 return ret;
2165 }
2166
2167 if (rxmode->mq_mode == RTE_ETH_MQ_RX_RSS)
2168 req_features |= (1ULL << VIRTIO_NET_F_RSS);
2169
2170 if (rxmode->mtu > hw->max_mtu)
2171 req_features &= ~(1ULL << VIRTIO_NET_F_MTU);
2172
2173 hw->max_rx_pkt_len = ether_hdr_len + rxmode->mtu;
2174
2175 if (rx_offloads & (RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
2176 RTE_ETH_RX_OFFLOAD_TCP_CKSUM))
2177 req_features |= (1ULL << VIRTIO_NET_F_GUEST_CSUM);
2178
2179 if (rx_offloads & RTE_ETH_RX_OFFLOAD_TCP_LRO)
2180 req_features |=
2181 (1ULL << VIRTIO_NET_F_GUEST_TSO4) |
2182 (1ULL << VIRTIO_NET_F_GUEST_TSO6);
2183
2184 if (tx_offloads & (RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
2185 RTE_ETH_TX_OFFLOAD_TCP_CKSUM))
2186 req_features |= (1ULL << VIRTIO_NET_F_CSUM);
2187
2188 if (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_TSO)

Callers

nothing calls this directly

Calls 8

virtio_init_deviceFunction · 0.85
virtio_with_featureFunction · 0.85
virtio_dev_cq_startFunction · 0.85
tx_offload_enabledFunction · 0.85
rx_offload_enabledFunction · 0.85
virtio_with_packed_queueFunction · 0.85
rte_cpu_get_flag_enabledFunction · 0.50

Tested by

no test coverage detected