net/octeontx: support set link up/down
[dpdk.git] / drivers / net / octeontx / base / octeontx_bgx.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Cavium, Inc
3  */
4
5 #ifndef __OCTEONTX_BGX_H__
6 #define __OCTEONTX_BGX_H__
7
8 #include <stdbool.h>
9 #include <stddef.h>
10 #include <stdint.h>
11
12 #include <octeontx_mbox.h>
13
14 #define OCTEONTX_BGX_COPROC             6
15
16 /* BGX messages */
17 #define MBOX_BGX_PORT_OPEN              0
18 #define MBOX_BGX_PORT_CLOSE             1
19 #define MBOX_BGX_PORT_START             2
20 #define MBOX_BGX_PORT_STOP              3
21 #define MBOX_BGX_PORT_GET_CONFIG        4
22 #define MBOX_BGX_PORT_GET_STATUS        5
23 #define MBOX_BGX_PORT_GET_STATS         6
24 #define MBOX_BGX_PORT_CLR_STATS         7
25 #define MBOX_BGX_PORT_GET_LINK_STATUS   8
26 #define MBOX_BGX_PORT_SET_PROMISC       9
27 #define MBOX_BGX_PORT_SET_MACADDR       10
28 #define MBOX_BGX_PORT_SET_BP            11
29 #define MBOX_BGX_PORT_SET_BCAST         12
30 #define MBOX_BGX_PORT_SET_MCAST         13
31 #define MBOX_BGX_PORT_SET_MTU           14
32 #define MBOX_BGX_PORT_ADD_MACADDR       15
33 #define MBOX_BGX_PORT_DEL_MACADDR       16
34 #define MBOX_BGX_PORT_GET_MACADDR_ENTRIES 17
35 #define MBOX_BGX_PORT_SET_LINK_STATE    20
36
37 /* BGX port configuration parameters: */
38 typedef struct octeontx_mbox_bgx_port_conf {
39         uint8_t enable;
40         uint8_t promisc;
41         uint8_t bpen;
42         uint8_t macaddr[6]; /* MAC address.*/
43         uint8_t fcs_strip;
44         uint8_t bcast_mode;
45         uint8_t mcast_mode;
46         uint8_t node; /* CPU node */
47         uint16_t base_chan;
48         uint16_t num_chans;
49         uint16_t mtu;
50         uint8_t bgx;
51         uint8_t lmac;
52         uint8_t mode;
53         uint8_t pkind;
54 } octeontx_mbox_bgx_port_conf_t;
55
56 /* BGX port status: */
57 typedef struct octeontx_mbox_bgx_port_status {
58         uint8_t link_up;
59         uint8_t bp;
60         uint8_t duplex;
61         uint32_t speed;
62 } octeontx_mbox_bgx_port_status_t;
63
64 /* BGX port statistics: */
65 typedef struct octeontx_mbox_bgx_port_stats {
66         uint64_t rx_packets;
67         uint64_t tx_packets;
68         uint64_t rx_bytes;
69         uint64_t tx_bytes;
70         uint64_t rx_errors;
71         uint64_t tx_errors;
72         uint64_t rx_dropped;
73         uint64_t tx_dropped;
74         uint64_t multicast;
75         uint64_t collisions;
76
77         uint64_t rx_length_errors;
78         uint64_t rx_over_errors;
79         uint64_t rx_crc_errors;
80         uint64_t rx_frame_errors;
81         uint64_t rx_fifo_errors;
82         uint64_t rx_missed_errors;
83
84         /* Detailed transmit errors. */
85         uint64_t tx_aborted_errors;
86         uint64_t tx_carrier_errors;
87         uint64_t tx_fifo_errors;
88         uint64_t tx_heartbeat_errors;
89         uint64_t tx_window_errors;
90
91         /* Extended statistics based on RFC2819. */
92         uint64_t rx_1_to_64_packets;
93         uint64_t rx_65_to_127_packets;
94         uint64_t rx_128_to_255_packets;
95         uint64_t rx_256_to_511_packets;
96         uint64_t rx_512_to_1023_packets;
97         uint64_t rx_1024_to_1522_packets;
98         uint64_t rx_1523_to_max_packets;
99
100         uint64_t tx_1_to_64_packets;
101         uint64_t tx_65_to_127_packets;
102         uint64_t tx_128_to_255_packets;
103         uint64_t tx_256_to_511_packets;
104         uint64_t tx_512_to_1023_packets;
105         uint64_t tx_1024_to_1522_packets;
106         uint64_t tx_1523_to_max_packets;
107
108         uint64_t tx_multicast_packets;
109         uint64_t rx_broadcast_packets;
110         uint64_t tx_broadcast_packets;
111         uint64_t rx_undersized_errors;
112         uint64_t rx_oversize_errors;
113         uint64_t rx_fragmented_errors;
114         uint64_t rx_jabber_errors;
115 } octeontx_mbox_bgx_port_stats_t;
116
117 struct octeontx_mbox_bgx_port_mac_filter {
118         uint8_t mac_addr[6];
119         int index;
120 };
121
122 int octeontx_bgx_port_open(int port, octeontx_mbox_bgx_port_conf_t *conf);
123 int octeontx_bgx_port_close(int port);
124 int octeontx_bgx_port_start(int port);
125 int octeontx_bgx_port_stop(int port);
126 int octeontx_bgx_port_get_config(int port, octeontx_mbox_bgx_port_conf_t *conf);
127 int octeontx_bgx_port_status(int port, octeontx_mbox_bgx_port_status_t *stat);
128 int octeontx_bgx_port_stats(int port, octeontx_mbox_bgx_port_stats_t *stats);
129 int octeontx_bgx_port_stats_clr(int port);
130 int octeontx_bgx_port_link_status(int port);
131 int octeontx_bgx_port_promisc_set(int port, int en);
132 int octeontx_bgx_port_mac_set(int port, uint8_t *mac_addr);
133 int octeontx_bgx_port_mac_add(int port, uint8_t *mac_addr, int index);
134 int octeontx_bgx_port_mac_del(int port, uint32_t index);
135 int octeontx_bgx_port_mac_entries_get(int port);
136 int octeontx_bgx_port_mtu_set(int port, int mtu);
137 int octeontx_bgx_port_set_link_state(int port, bool en);
138
139 #endif  /* __OCTEONTX_BGX_H__ */
140