4 * Copyright (C) Cavium Inc. 2017. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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
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.
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.
35 #include "octeontx_bgx.h"
38 octeontx_bgx_port_open(int port, octeontx_mbox_bgx_port_conf_t *conf)
40 struct octeontx_mbox_hdr hdr;
41 octeontx_mbox_bgx_port_conf_t bgx_conf;
42 int len = sizeof(octeontx_mbox_bgx_port_conf_t);
45 memset(&bgx_conf, 0, sizeof(octeontx_mbox_bgx_port_conf_t));
46 hdr.coproc = OCTEONTX_BGX_COPROC;
47 hdr.msg = MBOX_BGX_PORT_OPEN;
50 res = octeontx_ssovf_mbox_send(&hdr, NULL, 0, &bgx_conf, len);
54 conf->enable = bgx_conf.enable;
55 conf->promisc = bgx_conf.promisc;
56 conf->bpen = bgx_conf.bpen;
57 conf->node = bgx_conf.node;
58 conf->base_chan = bgx_conf.base_chan;
59 conf->num_chans = bgx_conf.num_chans;
60 conf->mtu = bgx_conf.mtu;
61 conf->bgx = bgx_conf.bgx;
62 conf->lmac = bgx_conf.lmac;
63 conf->mode = bgx_conf.mode;
64 conf->pkind = bgx_conf.pkind;
65 memcpy(conf->macaddr, bgx_conf.macaddr, 6);
71 octeontx_bgx_port_close(int port)
73 struct octeontx_mbox_hdr hdr;
76 hdr.coproc = OCTEONTX_BGX_COPROC;
77 hdr.msg = MBOX_BGX_PORT_CLOSE;
80 res = octeontx_ssovf_mbox_send(&hdr, NULL, 0, NULL, 0);
88 octeontx_bgx_port_start(int port)
90 struct octeontx_mbox_hdr hdr;
93 hdr.coproc = OCTEONTX_BGX_COPROC;
94 hdr.msg = MBOX_BGX_PORT_START;
97 res = octeontx_ssovf_mbox_send(&hdr, NULL, 0, NULL, 0);
105 octeontx_bgx_port_stop(int port)
107 struct octeontx_mbox_hdr hdr;
110 hdr.coproc = OCTEONTX_BGX_COPROC;
111 hdr.msg = MBOX_BGX_PORT_STOP;
114 res = octeontx_ssovf_mbox_send(&hdr, NULL, 0, NULL, 0);
122 octeontx_bgx_port_get_config(int port, octeontx_mbox_bgx_port_conf_t *conf)
124 struct octeontx_mbox_hdr hdr;
125 octeontx_mbox_bgx_port_conf_t bgx_conf;
126 int len = sizeof(octeontx_mbox_bgx_port_conf_t);
129 hdr.coproc = OCTEONTX_BGX_COPROC;
130 hdr.msg = MBOX_BGX_PORT_GET_CONFIG;
133 memset(&bgx_conf, 0, sizeof(octeontx_mbox_bgx_port_conf_t));
134 res = octeontx_ssovf_mbox_send(&hdr, NULL, 0, &bgx_conf, len);
138 conf->enable = bgx_conf.enable;
139 conf->promisc = bgx_conf.promisc;
140 conf->bpen = bgx_conf.bpen;
141 conf->node = bgx_conf.node;
142 conf->base_chan = bgx_conf.base_chan;
143 conf->num_chans = bgx_conf.num_chans;
144 conf->mtu = bgx_conf.mtu;
145 conf->bgx = bgx_conf.bgx;
146 conf->lmac = bgx_conf.lmac;
147 conf->mode = bgx_conf.mode;
148 conf->pkind = bgx_conf.pkind;
149 memcpy(conf->macaddr, bgx_conf.macaddr, 6);
155 octeontx_bgx_port_status(int port, octeontx_mbox_bgx_port_status_t *stat)
157 struct octeontx_mbox_hdr hdr;
158 octeontx_mbox_bgx_port_status_t bgx_stat;
159 int len = sizeof(octeontx_mbox_bgx_port_status_t);
162 hdr.coproc = OCTEONTX_BGX_COPROC;
163 hdr.msg = MBOX_BGX_PORT_GET_STATUS;
166 res = octeontx_ssovf_mbox_send(&hdr, NULL, 0, &bgx_stat, len);
170 stat->link_up = bgx_stat.link_up;
176 octeontx_bgx_port_stats(int port, octeontx_mbox_bgx_port_stats_t *stats)
178 struct octeontx_mbox_hdr hdr;
179 octeontx_mbox_bgx_port_stats_t bgx_stats;
180 int len = sizeof(octeontx_mbox_bgx_port_stats_t);
183 hdr.coproc = OCTEONTX_BGX_COPROC;
184 hdr.msg = MBOX_BGX_PORT_GET_STATS;
187 res = octeontx_ssovf_mbox_send(&hdr, NULL, 0, &bgx_stats, len);
191 stats->rx_packets = bgx_stats.rx_packets;
192 stats->rx_bytes = bgx_stats.rx_bytes;
193 stats->rx_dropped = bgx_stats.rx_dropped;
194 stats->rx_errors = bgx_stats.rx_errors;
195 stats->tx_packets = bgx_stats.tx_packets;
196 stats->tx_bytes = bgx_stats.tx_bytes;
197 stats->tx_dropped = bgx_stats.tx_dropped;
198 stats->tx_errors = bgx_stats.tx_errors;
203 octeontx_bgx_port_stats_clr(int port)
205 struct octeontx_mbox_hdr hdr;
208 hdr.coproc = OCTEONTX_BGX_COPROC;
209 hdr.msg = MBOX_BGX_PORT_CLR_STATS;
212 res = octeontx_ssovf_mbox_send(&hdr, NULL, 0, NULL, 0);
220 octeontx_bgx_port_link_status(int port)
222 struct octeontx_mbox_hdr hdr;
224 int len = sizeof(uint8_t);
227 hdr.coproc = OCTEONTX_BGX_COPROC;
228 hdr.msg = MBOX_BGX_PORT_GET_LINK_STATUS;
231 res = octeontx_ssovf_mbox_send(&hdr, NULL, 0, &link, len);
239 octeontx_bgx_port_promisc_set(int port, int en)
241 struct octeontx_mbox_hdr hdr;
245 hdr.coproc = OCTEONTX_BGX_COPROC;
246 hdr.msg = MBOX_BGX_PORT_SET_PROMISC;
250 res = octeontx_ssovf_mbox_send(&hdr, &prom, sizeof(prom), NULL, 0);
258 octeontx_bgx_port_mac_set(int port, uint8_t *mac_addr)
260 struct octeontx_mbox_hdr hdr;
264 hdr.coproc = OCTEONTX_BGX_COPROC;
265 hdr.msg = MBOX_BGX_PORT_SET_MACADDR;
268 res = octeontx_ssovf_mbox_send(&hdr, mac_addr, len, NULL, 0);