net: add rte prefix to IP structure
[dpdk.git] / drivers / net / vmxnet3 / vmxnet3_rxtx.c
index d30914a..5760902 100644 (file)
@@ -667,8 +667,8 @@ vmxnet3_guess_mss(struct vmxnet3_hw *hw, const Vmxnet3_RxCompDesc *rcd,
                struct rte_mbuf *rxm)
 {
        uint32_t hlen, slen;
-       struct ipv4_hdr *ipv4_hdr;
-       struct ipv6_hdr *ipv6_hdr;
+       struct rte_ipv4_hdr *ipv4_hdr;
+       struct rte_ipv6_hdr *ipv6_hdr;
        struct tcp_hdr *tcp_hdr;
        char *ptr;
 
@@ -676,23 +676,23 @@ vmxnet3_guess_mss(struct vmxnet3_hw *hw, const Vmxnet3_RxCompDesc *rcd,
 
        ptr = rte_pktmbuf_mtod(rxm, char *);
        slen = rte_pktmbuf_data_len(rxm);
-       hlen = sizeof(struct ether_hdr);
+       hlen = sizeof(struct rte_ether_hdr);
 
        if (rcd->v4) {
-               if (unlikely(slen < hlen + sizeof(struct ipv4_hdr)))
-                       return hw->mtu - sizeof(struct ipv4_hdr)
+               if (unlikely(slen < hlen + sizeof(struct rte_ipv4_hdr)))
+                       return hw->mtu - sizeof(struct rte_ipv4_hdr)
                                        - sizeof(struct tcp_hdr);
 
-               ipv4_hdr = (struct ipv4_hdr *)(ptr + hlen);
+               ipv4_hdr = (struct rte_ipv4_hdr *)(ptr + hlen);
                hlen += (ipv4_hdr->version_ihl & IPV4_HDR_IHL_MASK) *
                                IPV4_IHL_MULTIPLIER;
        } else if (rcd->v6) {
-               if (unlikely(slen < hlen + sizeof(struct ipv6_hdr)))
-                       return hw->mtu - sizeof(struct ipv6_hdr) -
+               if (unlikely(slen < hlen + sizeof(struct rte_ipv6_hdr)))
+                       return hw->mtu - sizeof(struct rte_ipv6_hdr) -
                                        sizeof(struct tcp_hdr);
 
-               ipv6_hdr = (struct ipv6_hdr *)(ptr + hlen);
-               hlen += sizeof(struct ipv6_hdr);
+               ipv6_hdr = (struct rte_ipv6_hdr *)(ptr + hlen);
+               hlen += sizeof(struct rte_ipv6_hdr);
                if (unlikely(ipv6_hdr->proto != IPPROTO_TCP)) {
                        int frag;
 
@@ -703,7 +703,7 @@ vmxnet3_guess_mss(struct vmxnet3_hw *hw, const Vmxnet3_RxCompDesc *rcd,
 
        if (unlikely(slen < hlen + sizeof(struct tcp_hdr)))
                return hw->mtu - hlen - sizeof(struct tcp_hdr) +
-                               sizeof(struct ether_hdr);
+                               sizeof(struct rte_ether_hdr);
 
        tcp_hdr = (struct tcp_hdr *)(ptr + hlen);
        hlen += (tcp_hdr->data_off & 0xf0) >> 2;
@@ -712,7 +712,7 @@ vmxnet3_guess_mss(struct vmxnet3_hw *hw, const Vmxnet3_RxCompDesc *rcd,
                return (rte_pktmbuf_pkt_len(rxm) - hlen +
                                rxm->udata64 - 1) / rxm->udata64;
        else
-               return hw->mtu - hlen + sizeof(struct ether_hdr);
+               return hw->mtu - hlen + sizeof(struct rte_ether_hdr);
 }
 
 /* Receive side checksum and other offloads */
@@ -1291,6 +1291,46 @@ static uint8_t rss_intel_key[40] = {
        0x6A, 0x42, 0xB7, 0x3B, 0xBE, 0xAC, 0x01, 0xFA,
 };
 
+/*
+ * Additional RSS configurations based on vmxnet v4+ APIs
+ */
+int
+vmxnet3_v4_rss_configure(struct rte_eth_dev *dev)
+{
+       struct vmxnet3_hw *hw = dev->data->dev_private;
+       Vmxnet3_DriverShared *shared = hw->shared;
+       Vmxnet3_CmdInfo *cmdInfo = &shared->cu.cmdInfo;
+       struct rte_eth_rss_conf *port_rss_conf;
+       uint64_t rss_hf;
+       uint32_t ret;
+
+       PMD_INIT_FUNC_TRACE();
+
+       cmdInfo->setRSSFields = 0;
+       port_rss_conf = &dev->data->dev_conf.rx_adv_conf.rss_conf;
+       rss_hf = port_rss_conf->rss_hf &
+               (VMXNET3_V4_RSS_MASK | VMXNET3_RSS_OFFLOAD_ALL);
+
+       if (rss_hf & ETH_RSS_NONFRAG_IPV4_TCP)
+               cmdInfo->setRSSFields |= VMXNET3_RSS_FIELDS_TCPIP4;
+       if (rss_hf & ETH_RSS_NONFRAG_IPV6_TCP)
+               cmdInfo->setRSSFields |= VMXNET3_RSS_FIELDS_TCPIP6;
+       if (rss_hf & ETH_RSS_NONFRAG_IPV4_UDP)
+               cmdInfo->setRSSFields |= VMXNET3_RSS_FIELDS_UDPIP4;
+       if (rss_hf & ETH_RSS_NONFRAG_IPV6_UDP)
+               cmdInfo->setRSSFields |= VMXNET3_RSS_FIELDS_UDPIP6;
+
+       VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD,
+                              VMXNET3_CMD_SET_RSS_FIELDS);
+       ret = VMXNET3_READ_BAR1_REG(hw, VMXNET3_REG_CMD);
+
+       if (ret != VMXNET3_SUCCESS) {
+               PMD_DRV_LOG(ERR, "Set RSS fields (v4) failed: %d", ret);
+       }
+
+       return ret;
+}
+
 /*
  * Configure RSS feature
  */