1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Cavium, Inc
5 #ifndef __OCTEONTX_BGX_H__
6 #define __OCTEONTX_BGX_H__
12 #include <octeontx_mbox.h>
14 #define OCTEONTX_BGX_RSVD_RX_FIFOBYTES 0x40
16 #define OCTEONTX_BGX_COPROC 6
19 #define MBOX_BGX_PORT_OPEN 0
20 #define MBOX_BGX_PORT_CLOSE 1
21 #define MBOX_BGX_PORT_START 2
22 #define MBOX_BGX_PORT_STOP 3
23 #define MBOX_BGX_PORT_GET_CONFIG 4
24 #define MBOX_BGX_PORT_GET_STATUS 5
25 #define MBOX_BGX_PORT_GET_STATS 6
26 #define MBOX_BGX_PORT_CLR_STATS 7
27 #define MBOX_BGX_PORT_GET_LINK_STATUS 8
28 #define MBOX_BGX_PORT_SET_PROMISC 9
29 #define MBOX_BGX_PORT_SET_MACADDR 10
30 #define MBOX_BGX_PORT_SET_BP 11
31 #define MBOX_BGX_PORT_SET_BCAST 12
32 #define MBOX_BGX_PORT_SET_MCAST 13
33 #define MBOX_BGX_PORT_SET_MTU 14
34 #define MBOX_BGX_PORT_ADD_MACADDR 15
35 #define MBOX_BGX_PORT_DEL_MACADDR 16
36 #define MBOX_BGX_PORT_GET_MACADDR_ENTRIES 17
37 #define MBOX_BGX_PORT_GET_FIFO_CFG 18
38 #define MBOX_BGX_PORT_FLOW_CTRL_CFG 19
39 #define MBOX_BGX_PORT_SET_LINK_STATE 20
41 /* BGX port configuration parameters: */
42 typedef struct octeontx_mbox_bgx_port_conf {
46 uint8_t macaddr[6]; /* MAC address.*/
50 uint8_t node; /* CPU node */
58 } octeontx_mbox_bgx_port_conf_t;
60 /* BGX port status: */
61 typedef struct octeontx_mbox_bgx_port_status {
66 } octeontx_mbox_bgx_port_status_t;
68 /* BGX port statistics: */
69 typedef struct octeontx_mbox_bgx_port_stats {
81 uint64_t rx_length_errors;
82 uint64_t rx_over_errors;
83 uint64_t rx_crc_errors;
84 uint64_t rx_frame_errors;
85 uint64_t rx_fifo_errors;
86 uint64_t rx_missed_errors;
88 /* Detailed transmit errors. */
89 uint64_t tx_aborted_errors;
90 uint64_t tx_carrier_errors;
91 uint64_t tx_fifo_errors;
92 uint64_t tx_heartbeat_errors;
93 uint64_t tx_window_errors;
95 /* Extended statistics based on RFC2819. */
96 uint64_t rx_1_to_64_packets;
97 uint64_t rx_65_to_127_packets;
98 uint64_t rx_128_to_255_packets;
99 uint64_t rx_256_to_511_packets;
100 uint64_t rx_512_to_1023_packets;
101 uint64_t rx_1024_to_1522_packets;
102 uint64_t rx_1523_to_max_packets;
104 uint64_t tx_1_to_64_packets;
105 uint64_t tx_65_to_127_packets;
106 uint64_t tx_128_to_255_packets;
107 uint64_t tx_256_to_511_packets;
108 uint64_t tx_512_to_1023_packets;
109 uint64_t tx_1024_to_1522_packets;
110 uint64_t tx_1523_to_max_packets;
112 uint64_t tx_multicast_packets;
113 uint64_t rx_broadcast_packets;
114 uint64_t tx_broadcast_packets;
115 uint64_t rx_undersized_errors;
116 uint64_t rx_oversize_errors;
117 uint64_t rx_fragmented_errors;
118 uint64_t rx_jabber_errors;
119 } octeontx_mbox_bgx_port_stats_t;
121 struct octeontx_mbox_bgx_port_mac_filter {
126 /* BGX port fifo config: */
127 typedef struct octeontx_mbox_bgx_port_fifo_cfg {
128 uint32_t rx_fifosz; /* in Bytes */
129 } octeontx_mbox_bgx_port_fifo_cfg_t;
132 BGX_PORT_FC_CFG_GET = 0,
133 BGX_PORT_FC_CFG_SET = 1
136 /* BGX port flow control config: */
137 typedef struct octeontx_mbox_bgx_port_fc_cfg {
138 /* BP on/off threshold levels in Bytes, must be a multiple of 16 */
141 uint8_t rx_pause; /* rx_pause = 1/0 to enable/disable fc on Tx */
142 uint8_t tx_pause; /* tx_pause = 1/0 to enable/disable fc on Rx */
143 bgx_port_fc_t fc_cfg;
144 } octeontx_mbox_bgx_port_fc_cfg_t;
146 int octeontx_bgx_port_open(int port, octeontx_mbox_bgx_port_conf_t *conf);
147 int octeontx_bgx_port_close(int port);
148 int octeontx_bgx_port_start(int port);
149 int octeontx_bgx_port_stop(int port);
150 int octeontx_bgx_port_get_config(int port, octeontx_mbox_bgx_port_conf_t *conf);
151 int octeontx_bgx_port_status(int port, octeontx_mbox_bgx_port_status_t *stat);
152 int octeontx_bgx_port_stats(int port, octeontx_mbox_bgx_port_stats_t *stats);
153 int octeontx_bgx_port_stats_clr(int port);
154 int octeontx_bgx_port_link_status(int port);
155 int octeontx_bgx_port_promisc_set(int port, int en);
156 int octeontx_bgx_port_mac_set(int port, uint8_t *mac_addr);
157 int octeontx_bgx_port_mac_add(int port, uint8_t *mac_addr, int index);
158 int octeontx_bgx_port_mac_del(int port, uint32_t index);
159 int octeontx_bgx_port_mac_entries_get(int port);
160 int octeontx_bgx_port_mtu_set(int port, int mtu);
161 int octeontx_bgx_port_set_link_state(int port, bool en);
162 int octeontx_bgx_port_get_fifo_cfg(int port,
163 octeontx_mbox_bgx_port_fifo_cfg_t *cfg);
164 int octeontx_bgx_port_flow_ctrl_cfg(int port,
165 octeontx_mbox_bgx_port_fc_cfg_t *cfg);
167 #endif /* __OCTEONTX_BGX_H__ */