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