Skip to content

Commit 4ebb86a

Browse files
shinas-marvellPaolo Abeni
authored and
Paolo Abeni
committed
octeon_ep: support firmware notifications for VFs
Notifications from firmware to vf has to pass through PF control mbox and via PF-VF mailboxes. The notifications have to be parsed out from the control mbox and passed to the PF-VF mailbox in order to reach the corresponding VF. Version compatibility should also be checked before messages are passed to the mailboxes. Signed-off-by: Shinas Rasheed <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent e28db8c commit 4ebb86a

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "octep_config.h"
1414
#include "octep_main.h"
1515
#include "octep_ctrl_net.h"
16+
#include "octep_pfvf_mbox.h"
1617

1718
/* Control plane version */
1819
#define OCTEP_CP_VERSION_CURRENT OCTEP_CP_VERSION(1, 0, 0)
@@ -329,6 +330,11 @@ static int process_mbox_notify(struct octep_device *oct,
329330
octep_ctrl_net_f2h_cmd_versions[cmd] < OCTEP_CP_VERSION_CURRENT)
330331
return -EOPNOTSUPP;
331332

333+
if (msg->hdr.s.is_vf) {
334+
octep_pfvf_notify(oct, msg);
335+
return 0;
336+
}
337+
332338
switch (cmd) {
333339
case OCTEP_CTRL_NET_F2H_CMD_LINK_STATUS:
334340
if (netif_running(netdev)) {

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

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@
2121
#include "octep_pfvf_mbox.h"
2222
#include "octep_ctrl_net.h"
2323

24+
/* When a new command is implemented, the below table should be updated
25+
* with new command and it's version info.
26+
*/
27+
static u32 pfvf_cmd_versions[OCTEP_PFVF_MBOX_CMD_MAX] = {
28+
[0 ... OCTEP_PFVF_MBOX_CMD_DEV_REMOVE] = OCTEP_PFVF_MBOX_VERSION_V1,
29+
[OCTEP_PFVF_MBOX_CMD_GET_FW_INFO ... OCTEP_PFVF_MBOX_NOTIF_LINK_STATUS] =
30+
OCTEP_PFVF_MBOX_VERSION_V2
31+
};
32+
2433
static void octep_pfvf_validate_version(struct octep_device *oct, u32 vf_id,
2534
union octep_pfvf_mbox_word cmd,
2635
union octep_pfvf_mbox_word *rsp)
@@ -87,6 +96,34 @@ static void octep_pfvf_set_rx_state(struct octep_device *oct, u32 vf_id,
8796
rsp->s_link_state.type = OCTEP_PFVF_MBOX_TYPE_RSP_ACK;
8897
}
8998

99+
static int octep_send_notification(struct octep_device *oct, u32 vf_id,
100+
union octep_pfvf_mbox_word cmd)
101+
{
102+
u32 max_rings_per_vf, vf_mbox_queue;
103+
struct octep_mbox *mbox;
104+
105+
/* check if VF PF Mailbox is compatible for this notification */
106+
if (pfvf_cmd_versions[cmd.s.opcode] > oct->vf_info[vf_id].mbox_version) {
107+
dev_dbg(&oct->pdev->dev, "VF Mbox doesn't support Notification:%d on VF ver:%d\n",
108+
cmd.s.opcode, oct->vf_info[vf_id].mbox_version);
109+
return -EOPNOTSUPP;
110+
}
111+
112+
max_rings_per_vf = CFG_GET_MAX_RPVF(oct->conf);
113+
vf_mbox_queue = vf_id * max_rings_per_vf;
114+
if (!oct->mbox[vf_mbox_queue]) {
115+
dev_err(&oct->pdev->dev, "Notif obtained for bad mbox vf %d\n", vf_id);
116+
return -EINVAL;
117+
}
118+
mbox = oct->mbox[vf_mbox_queue];
119+
120+
mutex_lock(&mbox->lock);
121+
writeq(cmd.u64, mbox->pf_vf_data_reg);
122+
mutex_unlock(&mbox->lock);
123+
124+
return 0;
125+
}
126+
90127
static void octep_pfvf_set_mtu(struct octep_device *oct, u32 vf_id,
91128
union octep_pfvf_mbox_word cmd,
92129
union octep_pfvf_mbox_word *rsp)
@@ -326,6 +363,27 @@ static void octep_pfvf_pf_get_data(struct octep_device *oct,
326363
}
327364
}
328365

366+
void octep_pfvf_notify(struct octep_device *oct, struct octep_ctrl_mbox_msg *msg)
367+
{
368+
union octep_pfvf_mbox_word notif = { 0 };
369+
struct octep_ctrl_net_f2h_req *req;
370+
371+
req = (struct octep_ctrl_net_f2h_req *)msg->sg_list[0].msg;
372+
switch (req->hdr.s.cmd) {
373+
case OCTEP_CTRL_NET_F2H_CMD_LINK_STATUS:
374+
notif.s_link_status.opcode = OCTEP_PFVF_MBOX_NOTIF_LINK_STATUS;
375+
notif.s_link_status.status = req->link.state;
376+
break;
377+
default:
378+
pr_info("Unknown mbox notif for vf: %u\n",
379+
req->hdr.s.cmd);
380+
return;
381+
}
382+
383+
notif.s.type = OCTEP_PFVF_MBOX_TYPE_CMD;
384+
octep_send_notification(oct, msg->hdr.s.vf_idx, notif);
385+
}
386+
329387
void octep_pfvf_mbox_work(struct work_struct *work)
330388
{
331389
struct octep_pfvf_mbox_wk *wk = container_of(work, struct octep_pfvf_mbox_wk, work);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ enum octep_pfvf_mbox_opcode {
3737
OCTEP_PFVF_MBOX_CMD_DEV_REMOVE,
3838
OCTEP_PFVF_MBOX_CMD_GET_FW_INFO,
3939
OCTEP_PFVF_MBOX_CMD_SET_OFFLOADS,
40+
OCTEP_PFVF_MBOX_NOTIF_LINK_STATUS,
4041
OCTEP_PFVF_MBOX_CMD_MAX,
4142
};
4243

@@ -162,4 +163,5 @@ union octep_pfvf_mbox_word {
162163
void octep_pfvf_mbox_work(struct work_struct *work);
163164
int octep_setup_pfvf_mbox(struct octep_device *oct);
164165
void octep_delete_pfvf_mbox(struct octep_device *oct);
166+
void octep_pfvf_notify(struct octep_device *oct, struct octep_ctrl_mbox_msg *msg);
165167
#endif

0 commit comments

Comments
 (0)