xref: /dpdk/drivers/net/octeontx/base/octeontx_bgx.h (revision 89ee1e94bc2d97ccb1ee00c834d81b1a895d0241)
1 /*
2  *   BSD LICENSE
3  *
4  *   Copyright (C) Cavium Inc. 2017. All rights reserved.
5  *
6  *   Redistribution and use in source and binary forms, with or without
7  *   modification, are permitted provided that the following conditions
8  *   are met:
9  *
10  *     * Redistributions of source code must retain the above copyright
11  *       notice, this list of conditions and the following disclaimer.
12  *     * Redistributions in binary form must reproduce the above copyright
13  *       notice, this list of conditions and the following disclaimer in
14  *       the documentation and/or other materials provided with the
15  *       distribution.
16  *     * Neither the name of Cavium networks nor the names of its
17  *       contributors may be used to endorse or promote products derived
18  *       from this software without specific prior written permission.
19  *
20  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef __OCTEONTX_BGX_H__
34 #define __OCTEONTX_BGX_H__
35 
36 #include <stddef.h>
37 #include <stdint.h>
38 
39 #include <octeontx_mbox.h>
40 
41 #define OCTEONTX_BGX_COPROC	        6
42 
43 /* BGX messages */
44 #define MBOX_BGX_PORT_OPEN              0
45 #define MBOX_BGX_PORT_CLOSE             1
46 #define MBOX_BGX_PORT_START             2
47 #define MBOX_BGX_PORT_STOP              3
48 #define MBOX_BGX_PORT_GET_CONFIG        4
49 #define MBOX_BGX_PORT_GET_STATUS        5
50 #define MBOX_BGX_PORT_GET_STATS         6
51 #define MBOX_BGX_PORT_CLR_STATS         7
52 #define MBOX_BGX_PORT_GET_LINK_STATUS   8
53 #define MBOX_BGX_PORT_SET_PROMISC       9
54 #define MBOX_BGX_PORT_SET_MACADDR       10
55 #define MBOX_BGX_PORT_SET_BP            11
56 #define MBOX_BGX_PORT_SET_BCAST         12
57 #define MBOX_BGX_PORT_SET_MCAST         13
58 
59 /* BGX port configuration parameters: */
60 typedef struct octeontx_mbox_bgx_port_conf {
61 	uint8_t enable;
62 	uint8_t promisc;
63 	uint8_t bpen;
64 	uint8_t macaddr[6]; /* MAC address.*/
65 	uint8_t fcs_strip;
66 	uint8_t bcast_mode;
67 	uint8_t mcast_mode;
68 	uint8_t node; /* CPU node */
69 	uint16_t base_chan;
70 	uint16_t num_chans;
71 	uint16_t mtu;
72 	uint8_t bgx;
73 	uint8_t lmac;
74 	uint8_t mode;
75 	uint8_t pkind;
76 } octeontx_mbox_bgx_port_conf_t;
77 
78 /* BGX port status: */
79 typedef struct octeontx_mbox_bgx_port_status {
80 	uint8_t link_up;
81 	uint8_t bp;
82 } octeontx_mbox_bgx_port_status_t;
83 
84 /* BGX port statistics: */
85 typedef struct octeontx_mbox_bgx_port_stats {
86 	uint64_t rx_packets;
87 	uint64_t tx_packets;
88 	uint64_t rx_bytes;
89 	uint64_t tx_bytes;
90 	uint64_t rx_errors;
91 	uint64_t tx_errors;
92 	uint64_t rx_dropped;
93 	uint64_t tx_dropped;
94 	uint64_t multicast;
95 	uint64_t collisions;
96 
97 	uint64_t rx_length_errors;
98 	uint64_t rx_over_errors;
99 	uint64_t rx_crc_errors;
100 	uint64_t rx_frame_errors;
101 	uint64_t rx_fifo_errors;
102 	uint64_t rx_missed_errors;
103 
104 	/* Detailed transmit errors. */
105 	uint64_t tx_aborted_errors;
106 	uint64_t tx_carrier_errors;
107 	uint64_t tx_fifo_errors;
108 	uint64_t tx_heartbeat_errors;
109 	uint64_t tx_window_errors;
110 
111 	/* Extended statistics based on RFC2819. */
112 	uint64_t rx_1_to_64_packets;
113 	uint64_t rx_65_to_127_packets;
114 	uint64_t rx_128_to_255_packets;
115 	uint64_t rx_256_to_511_packets;
116 	uint64_t rx_512_to_1023_packets;
117 	uint64_t rx_1024_to_1522_packets;
118 	uint64_t rx_1523_to_max_packets;
119 
120 	uint64_t tx_1_to_64_packets;
121 	uint64_t tx_65_to_127_packets;
122 	uint64_t tx_128_to_255_packets;
123 	uint64_t tx_256_to_511_packets;
124 	uint64_t tx_512_to_1023_packets;
125 	uint64_t tx_1024_to_1522_packets;
126 	uint64_t tx_1523_to_max_packets;
127 
128 	uint64_t tx_multicast_packets;
129 	uint64_t rx_broadcast_packets;
130 	uint64_t tx_broadcast_packets;
131 	uint64_t rx_undersized_errors;
132 	uint64_t rx_oversize_errors;
133 	uint64_t rx_fragmented_errors;
134 	uint64_t rx_jabber_errors;
135 } octeontx_mbox_bgx_port_stats_t;
136 
137 int octeontx_bgx_port_open(int port, octeontx_mbox_bgx_port_conf_t *conf);
138 int octeontx_bgx_port_close(int port);
139 int octeontx_bgx_port_start(int port);
140 int octeontx_bgx_port_stop(int port);
141 int octeontx_bgx_port_get_config(int port, octeontx_mbox_bgx_port_conf_t *conf);
142 int octeontx_bgx_port_status(int port, octeontx_mbox_bgx_port_status_t *stat);
143 int octeontx_bgx_port_stats(int port, octeontx_mbox_bgx_port_stats_t *stats);
144 int octeontx_bgx_port_stats_clr(int port);
145 int octeontx_bgx_port_link_status(int port);
146 int octeontx_bgx_port_promisc_set(int port, int en);
147 int octeontx_bgx_port_mac_set(int port, uint8_t *mac_addr);
148 
149 #endif	/* __OCTEONTX_BGX_H__ */
150 
151