xref: /dpdk/drivers/net/octeontx/base/octeontx_bgx.h (revision 89ee1e94bc2d97ccb1ee00c834d81b1a895d0241)
14d027880SJerin Jacob /*
24d027880SJerin Jacob  *   BSD LICENSE
34d027880SJerin Jacob  *
44d027880SJerin Jacob  *   Copyright (C) Cavium Inc. 2017. All rights reserved.
54d027880SJerin Jacob  *
64d027880SJerin Jacob  *   Redistribution and use in source and binary forms, with or without
74d027880SJerin Jacob  *   modification, are permitted provided that the following conditions
84d027880SJerin Jacob  *   are met:
94d027880SJerin Jacob  *
104d027880SJerin Jacob  *     * Redistributions of source code must retain the above copyright
114d027880SJerin Jacob  *       notice, this list of conditions and the following disclaimer.
124d027880SJerin Jacob  *     * Redistributions in binary form must reproduce the above copyright
134d027880SJerin Jacob  *       notice, this list of conditions and the following disclaimer in
144d027880SJerin Jacob  *       the documentation and/or other materials provided with the
154d027880SJerin Jacob  *       distribution.
164d027880SJerin Jacob  *     * Neither the name of Cavium networks nor the names of its
174d027880SJerin Jacob  *       contributors may be used to endorse or promote products derived
184d027880SJerin Jacob  *       from this software without specific prior written permission.
194d027880SJerin Jacob  *
204d027880SJerin Jacob  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
214d027880SJerin Jacob  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
224d027880SJerin Jacob  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
234d027880SJerin Jacob  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
244d027880SJerin Jacob  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
254d027880SJerin Jacob  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
264d027880SJerin Jacob  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
274d027880SJerin Jacob  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
284d027880SJerin Jacob  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
294d027880SJerin Jacob  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
304d027880SJerin Jacob  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
314d027880SJerin Jacob  */
324d027880SJerin Jacob 
334d027880SJerin Jacob #ifndef __OCTEONTX_BGX_H__
344d027880SJerin Jacob #define __OCTEONTX_BGX_H__
354d027880SJerin Jacob 
364d027880SJerin Jacob #include <stddef.h>
374d027880SJerin Jacob #include <stdint.h>
384d027880SJerin Jacob 
39*89ee1e94SSantosh Shukla #include <octeontx_mbox.h>
404d027880SJerin Jacob 
414d027880SJerin Jacob #define OCTEONTX_BGX_COPROC	        6
424d027880SJerin Jacob 
434d027880SJerin Jacob /* BGX messages */
444d027880SJerin Jacob #define MBOX_BGX_PORT_OPEN              0
454d027880SJerin Jacob #define MBOX_BGX_PORT_CLOSE             1
464d027880SJerin Jacob #define MBOX_BGX_PORT_START             2
474d027880SJerin Jacob #define MBOX_BGX_PORT_STOP              3
48e242dd1cSJerin Jacob #define MBOX_BGX_PORT_GET_CONFIG        4
49e242dd1cSJerin Jacob #define MBOX_BGX_PORT_GET_STATUS        5
50e242dd1cSJerin Jacob #define MBOX_BGX_PORT_GET_STATS         6
51e242dd1cSJerin Jacob #define MBOX_BGX_PORT_CLR_STATS         7
52e242dd1cSJerin Jacob #define MBOX_BGX_PORT_GET_LINK_STATUS   8
53e242dd1cSJerin Jacob #define MBOX_BGX_PORT_SET_PROMISC       9
54e242dd1cSJerin Jacob #define MBOX_BGX_PORT_SET_MACADDR       10
55e242dd1cSJerin Jacob #define MBOX_BGX_PORT_SET_BP            11
56e242dd1cSJerin Jacob #define MBOX_BGX_PORT_SET_BCAST         12
57e242dd1cSJerin Jacob #define MBOX_BGX_PORT_SET_MCAST         13
584d027880SJerin Jacob 
594d027880SJerin Jacob /* BGX port configuration parameters: */
604d027880SJerin Jacob typedef struct octeontx_mbox_bgx_port_conf {
614d027880SJerin Jacob 	uint8_t enable;
624d027880SJerin Jacob 	uint8_t promisc;
634d027880SJerin Jacob 	uint8_t bpen;
644d027880SJerin Jacob 	uint8_t macaddr[6]; /* MAC address.*/
654d027880SJerin Jacob 	uint8_t fcs_strip;
664d027880SJerin Jacob 	uint8_t bcast_mode;
674d027880SJerin Jacob 	uint8_t mcast_mode;
684d027880SJerin Jacob 	uint8_t node; /* CPU node */
694d027880SJerin Jacob 	uint16_t base_chan;
704d027880SJerin Jacob 	uint16_t num_chans;
714d027880SJerin Jacob 	uint16_t mtu;
724d027880SJerin Jacob 	uint8_t bgx;
734d027880SJerin Jacob 	uint8_t lmac;
744d027880SJerin Jacob 	uint8_t mode;
754d027880SJerin Jacob 	uint8_t pkind;
764d027880SJerin Jacob } octeontx_mbox_bgx_port_conf_t;
774d027880SJerin Jacob 
78e242dd1cSJerin Jacob /* BGX port status: */
79e242dd1cSJerin Jacob typedef struct octeontx_mbox_bgx_port_status {
80e242dd1cSJerin Jacob 	uint8_t link_up;
81e242dd1cSJerin Jacob 	uint8_t bp;
82e242dd1cSJerin Jacob } octeontx_mbox_bgx_port_status_t;
83e242dd1cSJerin Jacob 
84e242dd1cSJerin Jacob /* BGX port statistics: */
85e242dd1cSJerin Jacob typedef struct octeontx_mbox_bgx_port_stats {
86e242dd1cSJerin Jacob 	uint64_t rx_packets;
87e242dd1cSJerin Jacob 	uint64_t tx_packets;
88e242dd1cSJerin Jacob 	uint64_t rx_bytes;
89e242dd1cSJerin Jacob 	uint64_t tx_bytes;
90e242dd1cSJerin Jacob 	uint64_t rx_errors;
91e242dd1cSJerin Jacob 	uint64_t tx_errors;
92e242dd1cSJerin Jacob 	uint64_t rx_dropped;
93e242dd1cSJerin Jacob 	uint64_t tx_dropped;
94e242dd1cSJerin Jacob 	uint64_t multicast;
95e242dd1cSJerin Jacob 	uint64_t collisions;
96e242dd1cSJerin Jacob 
97e242dd1cSJerin Jacob 	uint64_t rx_length_errors;
98e242dd1cSJerin Jacob 	uint64_t rx_over_errors;
99e242dd1cSJerin Jacob 	uint64_t rx_crc_errors;
100e242dd1cSJerin Jacob 	uint64_t rx_frame_errors;
101e242dd1cSJerin Jacob 	uint64_t rx_fifo_errors;
102e242dd1cSJerin Jacob 	uint64_t rx_missed_errors;
103e242dd1cSJerin Jacob 
104e242dd1cSJerin Jacob 	/* Detailed transmit errors. */
105e242dd1cSJerin Jacob 	uint64_t tx_aborted_errors;
106e242dd1cSJerin Jacob 	uint64_t tx_carrier_errors;
107e242dd1cSJerin Jacob 	uint64_t tx_fifo_errors;
108e242dd1cSJerin Jacob 	uint64_t tx_heartbeat_errors;
109e242dd1cSJerin Jacob 	uint64_t tx_window_errors;
110e242dd1cSJerin Jacob 
111e242dd1cSJerin Jacob 	/* Extended statistics based on RFC2819. */
112e242dd1cSJerin Jacob 	uint64_t rx_1_to_64_packets;
113e242dd1cSJerin Jacob 	uint64_t rx_65_to_127_packets;
114e242dd1cSJerin Jacob 	uint64_t rx_128_to_255_packets;
115e242dd1cSJerin Jacob 	uint64_t rx_256_to_511_packets;
116e242dd1cSJerin Jacob 	uint64_t rx_512_to_1023_packets;
117e242dd1cSJerin Jacob 	uint64_t rx_1024_to_1522_packets;
118e242dd1cSJerin Jacob 	uint64_t rx_1523_to_max_packets;
119e242dd1cSJerin Jacob 
120e242dd1cSJerin Jacob 	uint64_t tx_1_to_64_packets;
121e242dd1cSJerin Jacob 	uint64_t tx_65_to_127_packets;
122e242dd1cSJerin Jacob 	uint64_t tx_128_to_255_packets;
123e242dd1cSJerin Jacob 	uint64_t tx_256_to_511_packets;
124e242dd1cSJerin Jacob 	uint64_t tx_512_to_1023_packets;
125e242dd1cSJerin Jacob 	uint64_t tx_1024_to_1522_packets;
126e242dd1cSJerin Jacob 	uint64_t tx_1523_to_max_packets;
127e242dd1cSJerin Jacob 
128e242dd1cSJerin Jacob 	uint64_t tx_multicast_packets;
129e242dd1cSJerin Jacob 	uint64_t rx_broadcast_packets;
130e242dd1cSJerin Jacob 	uint64_t tx_broadcast_packets;
131e242dd1cSJerin Jacob 	uint64_t rx_undersized_errors;
132e242dd1cSJerin Jacob 	uint64_t rx_oversize_errors;
133e242dd1cSJerin Jacob 	uint64_t rx_fragmented_errors;
134e242dd1cSJerin Jacob 	uint64_t rx_jabber_errors;
135e242dd1cSJerin Jacob } octeontx_mbox_bgx_port_stats_t;
136e242dd1cSJerin Jacob 
1374d027880SJerin Jacob int octeontx_bgx_port_open(int port, octeontx_mbox_bgx_port_conf_t *conf);
1384d027880SJerin Jacob int octeontx_bgx_port_close(int port);
1394d027880SJerin Jacob int octeontx_bgx_port_start(int port);
1404d027880SJerin Jacob int octeontx_bgx_port_stop(int port);
141e242dd1cSJerin Jacob int octeontx_bgx_port_get_config(int port, octeontx_mbox_bgx_port_conf_t *conf);
142e242dd1cSJerin Jacob int octeontx_bgx_port_status(int port, octeontx_mbox_bgx_port_status_t *stat);
143e242dd1cSJerin Jacob int octeontx_bgx_port_stats(int port, octeontx_mbox_bgx_port_stats_t *stats);
144e242dd1cSJerin Jacob int octeontx_bgx_port_stats_clr(int port);
145e242dd1cSJerin Jacob int octeontx_bgx_port_link_status(int port);
146e242dd1cSJerin Jacob int octeontx_bgx_port_promisc_set(int port, int en);
147e242dd1cSJerin Jacob int octeontx_bgx_port_mac_set(int port, uint8_t *mac_addr);
1484d027880SJerin Jacob 
1494d027880SJerin Jacob #endif	/* __OCTEONTX_BGX_H__ */
1504d027880SJerin Jacob 
151