58a38d9894f885c63ce004f24066392c769f79a1
[dpdk.git] / drivers / net / hinic / hinic_pmd_ethdev.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Huawei Technologies Co., Ltd
3  */
4
5 #ifndef _HINIC_PMD_ETHDEV_H_
6 #define _HINIC_PMD_ETHDEV_H_
7
8 #include <rte_ethdev.h>
9 #include <rte_ethdev_core.h>
10
11 #include "base/hinic_compat.h"
12 #include "base/hinic_pmd_cfg.h"
13
14 #define HINIC_DEV_NAME_LEN      32
15 #define HINIC_MAX_RX_QUEUES     64
16
17 /* mbuf pool for copy invalid mbuf segs */
18 #define HINIC_COPY_MEMPOOL_DEPTH        128
19 #define HINIC_COPY_MBUF_SIZE            4096
20
21 #define SIZE_8BYTES(size)       (ALIGN((u32)(size), 8) >> 3)
22
23 #define HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev) \
24         ((struct hinic_nic_dev *)(dev)->data->dev_private)
25
26 #define HINIC_MAX_QUEUE_DEPTH           4096
27 #define HINIC_MIN_QUEUE_DEPTH           128
28 #define HINIC_TXD_ALIGN                 1
29 #define HINIC_RXD_ALIGN                 1
30
31 #define HINIC_UINT32_BIT_SIZE      (CHAR_BIT * sizeof(uint32_t))
32 #define HINIC_VFTA_SIZE            (4096 / HINIC_UINT32_BIT_SIZE)
33
34 enum hinic_dev_status {
35         HINIC_DEV_INIT,
36         HINIC_DEV_CLOSE,
37         HINIC_DEV_START,
38         HINIC_DEV_INTR_EN,
39 };
40
41 /* Information about the fdir mode. */
42 struct hinic_hw_fdir_mask {
43         uint32_t src_ipv4_mask;
44         uint32_t dst_ipv4_mask;
45         uint16_t src_port_mask;
46         uint16_t dst_port_mask;
47 };
48
49 /* Flow Director attribute */
50 struct hinic_atr_input {
51         u32 dst_ip;
52         u32 src_ip;
53         u16 src_port;
54         u16 dst_port;
55 };
56
57 struct hinic_fdir_rule {
58         struct hinic_hw_fdir_mask mask;
59         struct hinic_atr_input hinic_fdir; /* key of fdir filter */
60         uint8_t queue; /* queue assigned when matched */
61 };
62
63 extern const struct rte_flow_ops hinic_flow_ops;
64
65 /* hinic nic_device */
66 struct hinic_nic_dev {
67         /* hardware device */
68         struct hinic_hwdev *hwdev;
69         struct hinic_txq **txqs;
70         struct hinic_rxq **rxqs;
71         struct rte_mempool *cpy_mpool;
72         u16 num_qps;
73         u16 num_sq;
74         u16 num_rq;
75         u16 mtu_size;
76         u8 rss_tmpl_idx;
77         u8 rss_indir_flag;
78         u8 num_rss;
79         u8 rx_queue_list[HINIC_MAX_RX_QUEUES];
80
81         u32 vfta[HINIC_VFTA_SIZE];      /* VLAN bitmap */
82
83         struct rte_ether_addr default_addr;
84         struct rte_ether_addr *mc_list;
85         /* info */
86         unsigned int flags;
87         struct nic_service_cap nic_cap;
88         u32 rx_mode_status;     /* promisc or allmulticast */
89         unsigned long dev_status;
90
91         /* dpdk only */
92         char proc_dev_name[HINIC_DEV_NAME_LEN];
93         /* PF0->COS4, PF1->COS5, PF2->COS6, PF3->COS7,
94          * vf: the same with associate pf
95          */
96         u32 default_cos;
97 };
98
99 #endif /* _HINIC_PMD_ETHDEV_H_ */