e0863c5de8d2e36cef2ddea2faf07e13674678bb
[dpdk.git] / drivers / net / ionic / ionic_lif.h
1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2  * Copyright(c) 2018-2019 Pensando Systems, Inc. All rights reserved.
3  */
4
5 #ifndef _IONIC_LIF_H_
6 #define _IONIC_LIF_H_
7
8 #include <inttypes.h>
9
10 #include <rte_ethdev.h>
11 #include <rte_ether.h>
12
13 #include "ionic_osdep.h"
14 #include "ionic_dev.h"
15 #include "ionic_rx_filter.h"
16
17 #define IONIC_ADMINQ_LENGTH     16      /* must be a power of two */
18 #define IONIC_NOTIFYQ_LENGTH    64      /* must be a power of two */
19
20 #define IONIC_QCQ_F_INITED      BIT(0)
21 #define IONIC_QCQ_F_SG          BIT(1)
22 #define IONIC_QCQ_F_INTR        BIT(2)
23 #define IONIC_QCQ_F_NOTIFYQ     BIT(3)
24
25 /* Queue / Completion Queue */
26 struct ionic_qcq {
27         struct ionic_queue q;        /**< Queue */
28         struct ionic_cq cq;          /**< Completion Queue */
29         struct ionic_lif *lif;       /**< LIF */
30         struct rte_mempool *mb_pool; /**< mbuf pool to populate the RX ring */
31         const struct rte_memzone *base_z;
32         void *base;
33         rte_iova_t base_pa;
34         uint32_t total_size;
35         uint32_t flags;
36         struct ionic_intr_info intr;
37 };
38
39 #define IONIC_LIF_F_INITED              BIT(0)
40 #define IONIC_LIF_F_LINK_CHECK_NEEDED   BIT(1)
41
42 #define IONIC_LIF_NAME_MAX_SZ           (32)
43
44 struct ionic_lif {
45         struct ionic_adapter *adapter;
46         struct rte_eth_dev *eth_dev;
47         uint16_t port_id;  /**< Device port identifier */
48         uint16_t mtu;
49         uint32_t index;
50         uint32_t hw_index;
51         uint32_t state;
52         uint32_t kern_pid;
53         rte_spinlock_t adminq_lock;
54         rte_spinlock_t adminq_service_lock;
55         struct ionic_qcq *adminqcq;
56         struct ionic_qcq *notifyqcq;
57         struct ionic_rx_filters rx_filters;
58         struct ionic_doorbell __iomem *kern_dbpage;
59         uint64_t last_eid;
60         uint64_t features;
61         uint32_t hw_features;
62         uint32_t rx_mode;
63         char name[IONIC_LIF_NAME_MAX_SZ];
64         uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
65         uint32_t info_sz;
66         struct ionic_lif_info *info;
67         rte_iova_t info_pa;
68         const struct rte_memzone *info_z;
69 };
70
71 int ionic_lif_identify(struct ionic_adapter *adapter);
72 int ionic_lifs_size(struct ionic_adapter *ionic);
73
74 int ionic_lif_alloc(struct ionic_lif *lif);
75 void ionic_lif_free(struct ionic_lif *lif);
76
77 int ionic_lif_init(struct ionic_lif *lif);
78 void ionic_lif_deinit(struct ionic_lif *lif);
79
80 int ionic_lif_start(struct ionic_lif *lif);
81 int ionic_lif_stop(struct ionic_lif *lif);
82
83 int ionic_lif_configure(struct ionic_lif *lif);
84 void ionic_lif_reset(struct ionic_lif *lif);
85
86 int ionic_intr_alloc(struct ionic_lif *lif, struct ionic_intr_info *intr);
87 void ionic_intr_free(struct ionic_lif *lif, struct ionic_intr_info *intr);
88
89 bool ionic_adminq_service(struct ionic_cq *cq, uint32_t cq_desc_index,
90         void *cb_arg);
91 int ionic_qcq_service(struct ionic_qcq *qcq, int budget, ionic_cq_cb cb,
92         void *cb_arg);
93
94 int ionic_lif_change_mtu(struct ionic_lif *lif, int new_mtu);
95
96 int ionic_dev_add_mac(struct rte_eth_dev *eth_dev,
97         struct rte_ether_addr *mac_addr,
98         uint32_t index __rte_unused, uint32_t pool __rte_unused);
99 void ionic_dev_remove_mac(struct rte_eth_dev *eth_dev,
100         uint32_t index __rte_unused);
101 int ionic_dev_set_mac(struct rte_eth_dev *eth_dev,
102         struct rte_ether_addr *mac_addr);
103 int ionic_dev_vlan_filter_set(struct rte_eth_dev *eth_dev, uint16_t vlan_id,
104         int on);
105 int ionic_dev_promiscuous_enable(struct rte_eth_dev *dev);
106 int ionic_dev_promiscuous_disable(struct rte_eth_dev *dev);
107 int ionic_dev_allmulticast_enable(struct rte_eth_dev *dev);
108 int ionic_dev_allmulticast_disable(struct rte_eth_dev *dev);
109
110 void ionic_qcq_free(struct ionic_qcq *qcq);
111
112 int ionic_qcq_enable(struct ionic_qcq *qcq);
113 int ionic_qcq_disable(struct ionic_qcq *qcq);
114
115 int ionic_lif_set_features(struct ionic_lif *lif);
116
117 int ionic_notifyq_handler(struct ionic_lif *lif, int budget);
118
119 #endif /* _IONIC_LIF_H_ */