Skip to content

Commit f25e596

Browse files
vburrudavem330
authored andcommitted
octeon_ep: include function id in mailbox commands
Extend control command structure to include vfid and update APIs to accept VF ID. Signed-off-by: Abhijit Ayarekar <[email protected]> Signed-off-by: Veerasenareddy Burru <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 577f0d1 commit f25e596

File tree

4 files changed

+63
-39
lines changed

4 files changed

+63
-39
lines changed

drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ static const u32 link_info_sz = sizeof(struct octep_ctrl_net_link_info);
2222
static const u32 get_stats_sz = sizeof(struct octep_ctrl_net_h2f_req_cmd_get_stats);
2323
static atomic_t ctrl_net_msg_id;
2424

25-
static void init_send_req(struct octep_ctrl_mbox_msg *msg, void *buf, u16 sz)
25+
static void init_send_req(struct octep_ctrl_mbox_msg *msg, void *buf,
26+
u16 sz, int vfid)
2627
{
2728
msg->hdr.s.flags = OCTEP_CTRL_MBOX_MSG_HDR_FLAG_REQ;
2829
msg->hdr.s.msg_id = atomic_inc_return(&ctrl_net_msg_id) &
@@ -31,6 +32,10 @@ static void init_send_req(struct octep_ctrl_mbox_msg *msg, void *buf, u16 sz)
3132
msg->sg_num = 1;
3233
msg->sg_list[0].msg = buf;
3334
msg->sg_list[0].sz = msg->hdr.s.sz;
35+
if (vfid != OCTEP_CTRL_NET_INVALID_VFID) {
36+
msg->hdr.s.is_vf = 1;
37+
msg->hdr.s.vf_idx = vfid;
38+
}
3439
}
3540

3641
static int octep_send_mbox_req(struct octep_device *oct,
@@ -91,13 +96,13 @@ int octep_ctrl_net_init(struct octep_device *oct)
9196
return 0;
9297
}
9398

94-
int octep_ctrl_net_get_link_status(struct octep_device *oct)
99+
int octep_ctrl_net_get_link_status(struct octep_device *oct, int vfid)
95100
{
96101
struct octep_ctrl_net_wait_data d = {0};
97102
struct octep_ctrl_net_h2f_req *req = &d.data.req;
98103
int err;
99104

100-
init_send_req(&d.msg, (void *)req, state_sz);
105+
init_send_req(&d.msg, (void *)req, state_sz, vfid);
101106
req->hdr.s.cmd = OCTEP_CTRL_NET_H2F_CMD_LINK_STATUS;
102107
req->link.cmd = OCTEP_CTRL_NET_CMD_GET;
103108
err = octep_send_mbox_req(oct, &d, true);
@@ -107,13 +112,13 @@ int octep_ctrl_net_get_link_status(struct octep_device *oct)
107112
return d.data.resp.link.state;
108113
}
109114

110-
int octep_ctrl_net_set_link_status(struct octep_device *oct, bool up,
115+
int octep_ctrl_net_set_link_status(struct octep_device *oct, int vfid, bool up,
111116
bool wait_for_response)
112117
{
113118
struct octep_ctrl_net_wait_data d = {0};
114119
struct octep_ctrl_net_h2f_req *req = &d.data.req;
115120

116-
init_send_req(&d.msg, req, state_sz);
121+
init_send_req(&d.msg, req, state_sz, vfid);
117122
req->hdr.s.cmd = OCTEP_CTRL_NET_H2F_CMD_LINK_STATUS;
118123
req->link.cmd = OCTEP_CTRL_NET_CMD_SET;
119124
req->link.state = (up) ? OCTEP_CTRL_NET_STATE_UP :
@@ -122,13 +127,13 @@ int octep_ctrl_net_set_link_status(struct octep_device *oct, bool up,
122127
return octep_send_mbox_req(oct, &d, wait_for_response);
123128
}
124129

125-
int octep_ctrl_net_set_rx_state(struct octep_device *oct, bool up,
130+
int octep_ctrl_net_set_rx_state(struct octep_device *oct, int vfid, bool up,
126131
bool wait_for_response)
127132
{
128133
struct octep_ctrl_net_wait_data d = {0};
129134
struct octep_ctrl_net_h2f_req *req = &d.data.req;
130135

131-
init_send_req(&d.msg, req, state_sz);
136+
init_send_req(&d.msg, req, state_sz, vfid);
132137
req->hdr.s.cmd = OCTEP_CTRL_NET_H2F_CMD_RX_STATE;
133138
req->link.cmd = OCTEP_CTRL_NET_CMD_SET;
134139
req->link.state = (up) ? OCTEP_CTRL_NET_STATE_UP :
@@ -137,13 +142,13 @@ int octep_ctrl_net_set_rx_state(struct octep_device *oct, bool up,
137142
return octep_send_mbox_req(oct, &d, wait_for_response);
138143
}
139144

140-
int octep_ctrl_net_get_mac_addr(struct octep_device *oct, u8 *addr)
145+
int octep_ctrl_net_get_mac_addr(struct octep_device *oct, int vfid, u8 *addr)
141146
{
142147
struct octep_ctrl_net_wait_data d = {0};
143148
struct octep_ctrl_net_h2f_req *req = &d.data.req;
144149
int err;
145150

146-
init_send_req(&d.msg, req, mac_sz);
151+
init_send_req(&d.msg, req, mac_sz, vfid);
147152
req->hdr.s.cmd = OCTEP_CTRL_NET_H2F_CMD_MAC;
148153
req->link.cmd = OCTEP_CTRL_NET_CMD_GET;
149154
err = octep_send_mbox_req(oct, &d, true);
@@ -155,43 +160,43 @@ int octep_ctrl_net_get_mac_addr(struct octep_device *oct, u8 *addr)
155160
return 0;
156161
}
157162

158-
int octep_ctrl_net_set_mac_addr(struct octep_device *oct, u8 *addr,
163+
int octep_ctrl_net_set_mac_addr(struct octep_device *oct, int vfid, u8 *addr,
159164
bool wait_for_response)
160165
{
161166
struct octep_ctrl_net_wait_data d = {0};
162167
struct octep_ctrl_net_h2f_req *req = &d.data.req;
163168

164-
init_send_req(&d.msg, req, mac_sz);
169+
init_send_req(&d.msg, req, mac_sz, vfid);
165170
req->hdr.s.cmd = OCTEP_CTRL_NET_H2F_CMD_MAC;
166171
req->mac.cmd = OCTEP_CTRL_NET_CMD_SET;
167172
memcpy(&req->mac.addr, addr, ETH_ALEN);
168173

169174
return octep_send_mbox_req(oct, &d, wait_for_response);
170175
}
171176

172-
int octep_ctrl_net_set_mtu(struct octep_device *oct, int mtu,
177+
int octep_ctrl_net_set_mtu(struct octep_device *oct, int vfid, int mtu,
173178
bool wait_for_response)
174179
{
175180
struct octep_ctrl_net_wait_data d = {0};
176181
struct octep_ctrl_net_h2f_req *req = &d.data.req;
177182

178-
init_send_req(&d.msg, req, mtu_sz);
183+
init_send_req(&d.msg, req, mtu_sz, vfid);
179184
req->hdr.s.cmd = OCTEP_CTRL_NET_H2F_CMD_MTU;
180185
req->mtu.cmd = OCTEP_CTRL_NET_CMD_SET;
181186
req->mtu.val = mtu;
182187

183188
return octep_send_mbox_req(oct, &d, wait_for_response);
184189
}
185190

186-
int octep_ctrl_net_get_if_stats(struct octep_device *oct)
191+
int octep_ctrl_net_get_if_stats(struct octep_device *oct, int vfid)
187192
{
188193
struct octep_ctrl_net_wait_data d = {0};
189194
struct octep_ctrl_net_h2f_req *req = &d.data.req;
190195
void __iomem *iface_rx_stats;
191196
void __iomem *iface_tx_stats;
192197
int err;
193198

194-
init_send_req(&d.msg, req, get_stats_sz);
199+
init_send_req(&d.msg, req, get_stats_sz, vfid);
195200
req->hdr.s.cmd = OCTEP_CTRL_NET_H2F_CMD_GET_IF_STATS;
196201
req->get_stats.offset = oct->ctrl_mbox_ifstats_offset;
197202
err = octep_send_mbox_req(oct, &d, true);
@@ -207,14 +212,14 @@ int octep_ctrl_net_get_if_stats(struct octep_device *oct)
207212
return 0;
208213
}
209214

210-
int octep_ctrl_net_get_link_info(struct octep_device *oct)
215+
int octep_ctrl_net_get_link_info(struct octep_device *oct, int vfid)
211216
{
212217
struct octep_ctrl_net_wait_data d = {0};
213218
struct octep_ctrl_net_h2f_req *req = &d.data.req;
214219
struct octep_ctrl_net_h2f_resp *resp;
215220
int err;
216221

217-
init_send_req(&d.msg, req, link_info_sz);
222+
init_send_req(&d.msg, req, link_info_sz, vfid);
218223
req->hdr.s.cmd = OCTEP_CTRL_NET_H2F_CMD_LINK_INFO;
219224
req->link_info.cmd = OCTEP_CTRL_NET_CMD_GET;
220225
err = octep_send_mbox_req(oct, &d, true);
@@ -231,14 +236,14 @@ int octep_ctrl_net_get_link_info(struct octep_device *oct)
231236
return 0;
232237
}
233238

234-
int octep_ctrl_net_set_link_info(struct octep_device *oct,
239+
int octep_ctrl_net_set_link_info(struct octep_device *oct, int vfid,
235240
struct octep_iface_link_info *link_info,
236241
bool wait_for_response)
237242
{
238243
struct octep_ctrl_net_wait_data d = {0};
239244
struct octep_ctrl_net_h2f_req *req = &d.data.req;
240245

241-
init_send_req(&d.msg, req, link_info_sz);
246+
init_send_req(&d.msg, req, link_info_sz, vfid);
242247
req->hdr.s.cmd = OCTEP_CTRL_NET_H2F_CMD_LINK_INFO;
243248
req->link_info.cmd = OCTEP_CTRL_NET_CMD_SET;
244249
req->link_info.info.advertised_modes = link_info->advertised_modes;

drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.h

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#ifndef __OCTEP_CTRL_NET_H__
88
#define __OCTEP_CTRL_NET_H__
99

10+
#define OCTEP_CTRL_NET_INVALID_VFID (-1)
11+
1012
/* Supported commands */
1113
enum octep_ctrl_net_cmd {
1214
OCTEP_CTRL_NET_CMD_GET = 0,
@@ -216,89 +218,99 @@ int octep_ctrl_net_init(struct octep_device *oct);
216218
/** Get link status from firmware.
217219
*
218220
* @param oct: non-null pointer to struct octep_device.
221+
* @param vfid: Index of virtual function.
219222
*
220223
* return value: link status 0=down, 1=up.
221224
*/
222-
int octep_ctrl_net_get_link_status(struct octep_device *oct);
225+
int octep_ctrl_net_get_link_status(struct octep_device *oct, int vfid);
223226

224227
/** Set link status in firmware.
225228
*
226229
* @param oct: non-null pointer to struct octep_device.
230+
* @param vfid: Index of virtual function.
227231
* @param up: boolean status.
228232
* @param wait_for_response: poll for response.
229233
*
230234
* return value: 0 on success, -errno on failure
231235
*/
232-
int octep_ctrl_net_set_link_status(struct octep_device *oct, bool up,
236+
int octep_ctrl_net_set_link_status(struct octep_device *oct, int vfid, bool up,
233237
bool wait_for_response);
234238

235239
/** Set rx state in firmware.
236240
*
237241
* @param oct: non-null pointer to struct octep_device.
242+
* @param vfid: Index of virtual function.
238243
* @param up: boolean status.
239244
* @param wait_for_response: poll for response.
240245
*
241246
* return value: 0 on success, -errno on failure.
242247
*/
243-
int octep_ctrl_net_set_rx_state(struct octep_device *oct, bool up,
248+
int octep_ctrl_net_set_rx_state(struct octep_device *oct, int vfid, bool up,
244249
bool wait_for_response);
245250

246251
/** Get mac address from firmware.
247252
*
248253
* @param oct: non-null pointer to struct octep_device.
254+
* @param vfid: Index of virtual function.
249255
* @param addr: non-null pointer to mac address.
250256
*
251257
* return value: 0 on success, -errno on failure.
252258
*/
253-
int octep_ctrl_net_get_mac_addr(struct octep_device *oct, u8 *addr);
259+
int octep_ctrl_net_get_mac_addr(struct octep_device *oct, int vfid, u8 *addr);
254260

255261
/** Set mac address in firmware.
256262
*
257263
* @param oct: non-null pointer to struct octep_device.
264+
* @param vfid: Index of virtual function.
258265
* @param addr: non-null pointer to mac address.
259266
* @param wait_for_response: poll for response.
260267
*
261268
* return value: 0 on success, -errno on failure.
262269
*/
263-
int octep_ctrl_net_set_mac_addr(struct octep_device *oct, u8 *addr,
270+
int octep_ctrl_net_set_mac_addr(struct octep_device *oct, int vfid, u8 *addr,
264271
bool wait_for_response);
265272

266273
/** Set mtu in firmware.
267274
*
268275
* @param oct: non-null pointer to struct octep_device.
276+
* @param vfid: Index of virtual function.
269277
* @param mtu: mtu.
270278
* @param wait_for_response: poll for response.
271279
*
272280
* return value: 0 on success, -errno on failure.
273281
*/
274-
int octep_ctrl_net_set_mtu(struct octep_device *oct, int mtu,
282+
int octep_ctrl_net_set_mtu(struct octep_device *oct, int vfid, int mtu,
275283
bool wait_for_response);
276284

277285
/** Get interface statistics from firmware.
278286
*
279287
* @param oct: non-null pointer to struct octep_device.
288+
* @param vfid: Index of virtual function.
280289
*
281290
* return value: 0 on success, -errno on failure.
282291
*/
283-
int octep_ctrl_net_get_if_stats(struct octep_device *oct);
292+
int octep_ctrl_net_get_if_stats(struct octep_device *oct, int vfid);
284293

285294
/** Get link info from firmware.
286295
*
287296
* @param oct: non-null pointer to struct octep_device.
297+
* @param vfid: Index of virtual function.
288298
*
289299
* return value: 0 on success, -errno on failure.
290300
*/
291-
int octep_ctrl_net_get_link_info(struct octep_device *oct);
301+
int octep_ctrl_net_get_link_info(struct octep_device *oct, int vfid);
292302

293303
/** Set link info in firmware.
294304
*
295305
* @param oct: non-null pointer to struct octep_device.
306+
* @param vfid: Index of virtual function.
296307
* @param link_info: non-null pointer to struct octep_iface_link_info.
297308
* @param wait_for_response: poll for response.
298309
*
299310
* return value: 0 on success, -errno on failure.
300311
*/
301312
int octep_ctrl_net_set_link_info(struct octep_device *oct,
313+
int vfid,
302314
struct octep_iface_link_info *link_info,
303315
bool wait_for_response);
304316

drivers/net/ethernet/marvell/octeon_ep/octep_ethtool.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ octep_get_ethtool_stats(struct net_device *netdev,
150150
rx_packets = 0;
151151
rx_bytes = 0;
152152

153-
octep_ctrl_net_get_if_stats(oct);
153+
octep_ctrl_net_get_if_stats(oct, OCTEP_CTRL_NET_INVALID_VFID);
154154
iface_tx_stats = &oct->iface_tx_stats;
155155
iface_rx_stats = &oct->iface_rx_stats;
156156

@@ -283,7 +283,7 @@ static int octep_get_link_ksettings(struct net_device *netdev,
283283
ethtool_link_ksettings_zero_link_mode(cmd, supported);
284284
ethtool_link_ksettings_zero_link_mode(cmd, advertising);
285285

286-
octep_ctrl_net_get_link_info(oct);
286+
octep_ctrl_net_get_link_info(oct, OCTEP_CTRL_NET_INVALID_VFID);
287287

288288
advertised_modes = oct->link_info.advertised_modes;
289289
supported_modes = oct->link_info.supported_modes;
@@ -439,7 +439,8 @@ static int octep_set_link_ksettings(struct net_device *netdev,
439439
link_info_new.speed = cmd->base.speed;
440440
link_info_new.autoneg = autoneg;
441441

442-
err = octep_ctrl_net_set_link_info(oct, &link_info_new, true);
442+
err = octep_ctrl_net_set_link_info(oct, OCTEP_CTRL_NET_INVALID_VFID,
443+
&link_info_new, true);
443444
if (err)
444445
return err;
445446

drivers/net/ethernet/marvell/octeon_ep/octep_main.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,10 @@ static int octep_open(struct net_device *netdev)
507507
octep_napi_enable(oct);
508508

509509
oct->link_info.admin_up = 1;
510-
octep_ctrl_net_set_rx_state(oct, true, false);
511-
octep_ctrl_net_set_link_status(oct, true, false);
510+
octep_ctrl_net_set_rx_state(oct, OCTEP_CTRL_NET_INVALID_VFID, true,
511+
false);
512+
octep_ctrl_net_set_link_status(oct, OCTEP_CTRL_NET_INVALID_VFID, true,
513+
false);
512514
oct->poll_non_ioq_intr = false;
513515

514516
/* Enable the input and output queues for this Octeon device */
@@ -519,7 +521,7 @@ static int octep_open(struct net_device *netdev)
519521

520522
octep_oq_dbell_init(oct);
521523

522-
ret = octep_ctrl_net_get_link_status(oct);
524+
ret = octep_ctrl_net_get_link_status(oct, OCTEP_CTRL_NET_INVALID_VFID);
523525
if (ret > 0)
524526
octep_link_up(netdev);
525527

@@ -549,8 +551,10 @@ static int octep_stop(struct net_device *netdev)
549551

550552
netdev_info(netdev, "Stopping the device ...\n");
551553

552-
octep_ctrl_net_set_link_status(oct, false, false);
553-
octep_ctrl_net_set_rx_state(oct, false, false);
554+
octep_ctrl_net_set_link_status(oct, OCTEP_CTRL_NET_INVALID_VFID, false,
555+
false);
556+
octep_ctrl_net_set_rx_state(oct, OCTEP_CTRL_NET_INVALID_VFID, false,
557+
false);
554558

555559
/* Stop Tx from stack */
556560
netif_tx_stop_all_queues(netdev);
@@ -759,7 +763,7 @@ static void octep_get_stats64(struct net_device *netdev,
759763
int q;
760764

761765
if (netif_running(netdev))
762-
octep_ctrl_net_get_if_stats(oct);
766+
octep_ctrl_net_get_if_stats(oct, OCTEP_CTRL_NET_INVALID_VFID);
763767

764768
tx_packets = 0;
765769
tx_bytes = 0;
@@ -831,7 +835,8 @@ static int octep_set_mac(struct net_device *netdev, void *p)
831835
if (!is_valid_ether_addr(addr->sa_data))
832836
return -EADDRNOTAVAIL;
833837

834-
err = octep_ctrl_net_set_mac_addr(oct, addr->sa_data, true);
838+
err = octep_ctrl_net_set_mac_addr(oct, OCTEP_CTRL_NET_INVALID_VFID,
839+
addr->sa_data, true);
835840
if (err)
836841
return err;
837842

@@ -851,7 +856,8 @@ static int octep_change_mtu(struct net_device *netdev, int new_mtu)
851856
if (link_info->mtu == new_mtu)
852857
return 0;
853858

854-
err = octep_ctrl_net_set_mtu(oct, new_mtu, true);
859+
err = octep_ctrl_net_set_mtu(oct, OCTEP_CTRL_NET_INVALID_VFID, new_mtu,
860+
true);
855861
if (!err) {
856862
oct->link_info.mtu = new_mtu;
857863
netdev->mtu = new_mtu;
@@ -1102,7 +1108,7 @@ static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
11021108
netdev->max_mtu = OCTEP_MAX_MTU;
11031109
netdev->mtu = OCTEP_DEFAULT_MTU;
11041110

1105-
err = octep_ctrl_net_get_mac_addr(octep_dev,
1111+
err = octep_ctrl_net_get_mac_addr(octep_dev, OCTEP_CTRL_NET_INVALID_VFID,
11061112
octep_dev->mac_addr);
11071113
if (err) {
11081114
dev_err(&pdev->dev, "Failed to get mac address\n");

0 commit comments

Comments
 (0)