2 * Copyright 2008-2014 Cisco Systems, Inc. All rights reserved.
3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
5 * Copyright (c) 2014, Cisco Systems, Inc.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
39 #include "vnic_enet.h"
44 #include "vnic_intr.h"
45 #include "vnic_stats.h"
50 #define DRV_NAME "enic_pmd"
51 #define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Poll-mode Driver"
52 #define DRV_VERSION "1.0.0.4"
53 #define DRV_COPYRIGHT "Copyright 2008-2014 Cisco Systems, Inc"
57 #define ENIC_CQ_MAX (ENIC_WQ_MAX + ENIC_RQ_MAX)
58 #define ENIC_INTR_MAX (ENIC_CQ_MAX + 2)
60 #define VLAN_ETH_HLEN 18
62 #define ENICPMD_SETTING(enic, f) ((enic->config.flags & VENETF_##f) ? 1 : 0)
64 #define ENICPMD_BDF_LENGTH 13 /* 0000:00:00.0'\0' */
65 #define PKT_TX_TCP_UDP_CKSUM 0x6000
66 #define ENIC_CALC_IP_CKSUM 1
67 #define ENIC_CALC_TCP_UDP_CKSUM 2
68 #define ENIC_MAX_MTU 9000
69 #define PAGE_SIZE 4096
70 #define PAGE_ROUND_UP(x) \
71 ((((unsigned long)(x)) + PAGE_SIZE-1) & (~(PAGE_SIZE-1)))
73 #define ENICPMD_VFIO_PATH "/dev/vfio/vfio"
74 /*#define ENIC_DESC_COUNT_MAKE_ODD (x) do{if ((~(x)) & 1) { (x)--; } }while(0)*/
76 #define PCI_DEVICE_ID_CISCO_VIC_ENET 0x0043 /* ethernet vnic */
77 #define PCI_DEVICE_ID_CISCO_VIC_ENET_VF 0x0071 /* enet SRIOV VF */
80 #define ENICPMD_FDIR_MAX 64
82 struct enic_fdir_node {
83 struct rte_fdir_filter filter;
89 struct rte_eth_fdir stats;
90 struct rte_hash *hash;
91 struct enic_fdir_node *nodes[ENICPMD_FDIR_MAX];
94 /* Per-instance private data structure */
97 struct rte_pci_device *pdev;
98 struct vnic_enet_config config;
99 struct vnic_dev_bar bar0;
100 struct vnic_dev *vdev;
102 struct rte_eth_dev *rte_dev;
103 struct enic_fdir fdir;
104 char bdf_name[ENICPMD_BDF_LENGTH];
109 u_int8_t mac_addr[ETH_ALEN];
110 pthread_t err_intr_thread;
113 int ig_vlan_strip_en;
118 unsigned int priv_flags;
121 struct vnic_wq wq[ENIC_WQ_MAX];
122 unsigned int wq_count;
125 struct vnic_rq rq[ENIC_RQ_MAX];
126 unsigned int rq_count;
128 /* completion queue */
129 struct vnic_cq cq[ENIC_CQ_MAX];
130 unsigned int cq_count;
132 /* interrupt resource */
133 struct vnic_intr intr;
134 unsigned int intr_count;
137 static inline unsigned int enic_cq_rq(struct enic *enic, unsigned int rq)
142 static inline unsigned int enic_cq_wq(struct enic *enic, unsigned int wq)
144 return enic->rq_count + wq;
147 static inline unsigned int enic_msix_err_intr(struct enic *enic)
152 static inline struct enic *pmd_priv(struct rte_eth_dev *eth_dev)
154 return (struct enic *)eth_dev->data->dev_private;
157 #endif /* _ENIC_H_ */