Skip to content

Commit 67fa756

Browse files
author
Paolo Abeni
committed
Merge branch 'octeontx2-improve-mailbox-tracing'
Subbaraya Sundeep says: ==================== octeontx2: Improve mailbox tracing Octeontx2 VF,PF and AF devices communicate using hardware shared mailbox region where VFs can only to talk to its PFs and PFs can only talk to AF. AF does the entire resource management for all PFs and VFs. The shared mbox region is used for synchronous requests (requests from PF to AF or VF to PF) and async notifications (notifications from AF to PFs or PF to VFs). Sending a request to AF from VF involves various stages like 1. VF allocates message in shared region 2. Triggers interrupt to PF 3. PF upon receiving interrupt from VF will copy the message from VF<->PF region to PF<->AF region 4. Triggers interrupt to AF 5. AF processes it and writes response in PF<->AF region 6. Triggers interrupt to PF 7. PF copies responses from PF<->AF region to VF<->PF region 8. Triggers interrupt to Vf 9. VF reads response in VF<->PF region Due to various stages involved, Tracepoints are used in mailbox code for debugging. Existing tracepoints need some improvements so that maximum information can be inferred from trace logs during an issue. This patchset tries to enhance existing tracepoints and also adds a couple of tracepoints. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents c166080 + fa00077 commit 67fa756

File tree

8 files changed

+91
-20
lines changed

8 files changed

+91
-20
lines changed

drivers/net/ethernet/marvell/octeontx2/af/mbox.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,13 @@ int otx2_mbox_wait_for_rsp(struct otx2_mbox *mbox, int devid)
188188
{
189189
unsigned long timeout = jiffies + msecs_to_jiffies(MBOX_RSP_TIMEOUT);
190190
struct otx2_mbox_dev *mdev = &mbox->dev[devid];
191-
struct device *sender = &mbox->pdev->dev;
192191

193192
while (!time_after(jiffies, timeout)) {
194193
if (mdev->num_msgs == mdev->msgs_acked)
195194
return 0;
196195
usleep_range(800, 1000);
197196
}
198-
dev_dbg(sender, "timed out while waiting for rsp\n");
197+
trace_otx2_msg_wait_rsp(mbox->pdev);
199198
return -EIO;
200199
}
201200
EXPORT_SYMBOL(otx2_mbox_wait_for_rsp);
@@ -219,6 +218,7 @@ static void otx2_mbox_msg_send_data(struct otx2_mbox *mbox, int devid, u64 data)
219218
struct otx2_mbox_dev *mdev = &mbox->dev[devid];
220219
struct mbox_hdr *tx_hdr, *rx_hdr;
221220
void *hw_mbase = mdev->hwbase;
221+
struct mbox_msghdr *msg;
222222
u64 intr_val;
223223

224224
tx_hdr = hw_mbase + mbox->tx_start;
@@ -251,7 +251,10 @@ static void otx2_mbox_msg_send_data(struct otx2_mbox *mbox, int devid, u64 data)
251251
tx_hdr->num_msgs = mdev->num_msgs;
252252
rx_hdr->num_msgs = 0;
253253

254-
trace_otx2_msg_send(mbox->pdev, tx_hdr->num_msgs, tx_hdr->msg_size);
254+
msg = (struct mbox_msghdr *)(hw_mbase + mbox->tx_start + msgs_offset);
255+
256+
trace_otx2_msg_send(mbox->pdev, tx_hdr->num_msgs, tx_hdr->msg_size,
257+
msg->id, msg->pcifunc);
255258

256259
spin_unlock(&mdev->mbox_lock);
257260

@@ -445,6 +448,14 @@ const char *otx2_mbox_id2name(u16 id)
445448
#define M(_name, _id, _1, _2, _3) case _id: return # _name;
446449
MBOX_MESSAGES
447450
#undef M
451+
452+
#define M(_name, _id, _1, _2, _3) case _id: return # _name;
453+
MBOX_UP_CGX_MESSAGES
454+
#undef M
455+
456+
#define M(_name, _id, _1, _2, _3) case _id: return # _name;
457+
MBOX_UP_CPT_MESSAGES
458+
#undef M
448459
default:
449460
return "INVALID ID";
450461
}

drivers/net/ethernet/marvell/octeontx2/af/rvu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2173,7 +2173,7 @@ static int rvu_process_mbox_msg(struct otx2_mbox *mbox, int devid,
21732173
if (rsp && err) \
21742174
rsp->hdr.rc = err; \
21752175
\
2176-
trace_otx2_msg_process(mbox->pdev, _id, err); \
2176+
trace_otx2_msg_process(mbox->pdev, _id, err, req->pcifunc); \
21772177
return rsp ? err : -ENOMEM; \
21782178
}
21792179
MBOX_MESSAGES

drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static struct _req_type __maybe_unused \
3434
return NULL; \
3535
req->hdr.sig = OTX2_MBOX_REQ_SIG; \
3636
req->hdr.id = _id; \
37-
trace_otx2_msg_alloc(rvu->pdev, _id, sizeof(*req)); \
37+
trace_otx2_msg_alloc(rvu->pdev, _id, sizeof(*req), 0); \
3838
return req; \
3939
}
4040

drivers/net/ethernet/marvell/octeontx2/af/rvu_trace.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
EXPORT_TRACEPOINT_SYMBOL(otx2_msg_alloc);
1212
EXPORT_TRACEPOINT_SYMBOL(otx2_msg_interrupt);
1313
EXPORT_TRACEPOINT_SYMBOL(otx2_msg_process);
14+
EXPORT_TRACEPOINT_SYMBOL(otx2_msg_status);

drivers/net/ethernet/marvell/octeontx2/af/rvu_trace.h

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,42 @@
1818
#include "mbox.h"
1919

2020
TRACE_EVENT(otx2_msg_alloc,
21-
TP_PROTO(const struct pci_dev *pdev, u16 id, u64 size),
22-
TP_ARGS(pdev, id, size),
21+
TP_PROTO(const struct pci_dev *pdev, u16 id, u64 size, u16 pcifunc),
22+
TP_ARGS(pdev, id, size, pcifunc),
2323
TP_STRUCT__entry(__string(dev, pci_name(pdev))
2424
__field(u16, id)
2525
__field(u64, size)
26+
__field(u16, pcifunc)
2627
),
2728
TP_fast_assign(__assign_str(dev);
2829
__entry->id = id;
2930
__entry->size = size;
31+
__entry->pcifunc = pcifunc;
3032
),
31-
TP_printk("[%s] msg:(%s) size:%lld\n", __get_str(dev),
32-
otx2_mbox_id2name(__entry->id), __entry->size)
33+
TP_printk("[%s] msg:(%s) size:%lld pcifunc:0x%x\n", __get_str(dev),
34+
otx2_mbox_id2name(__entry->id), __entry->size,
35+
__entry->pcifunc)
3336
);
3437

3538
TRACE_EVENT(otx2_msg_send,
36-
TP_PROTO(const struct pci_dev *pdev, u16 num_msgs, u64 msg_size),
37-
TP_ARGS(pdev, num_msgs, msg_size),
39+
TP_PROTO(const struct pci_dev *pdev, u16 num_msgs, u64 msg_size,
40+
u16 id, u16 pcifunc),
41+
TP_ARGS(pdev, num_msgs, msg_size, id, pcifunc),
3842
TP_STRUCT__entry(__string(dev, pci_name(pdev))
3943
__field(u16, num_msgs)
4044
__field(u64, msg_size)
45+
__field(u16, id)
46+
__field(u16, pcifunc)
4147
),
4248
TP_fast_assign(__assign_str(dev);
4349
__entry->num_msgs = num_msgs;
4450
__entry->msg_size = msg_size;
51+
__entry->id = id;
52+
__entry->pcifunc = pcifunc;
4553
),
46-
TP_printk("[%s] sent %d msg(s) of size:%lld\n", __get_str(dev),
47-
__entry->num_msgs, __entry->msg_size)
54+
TP_printk("[%s] sent %d msg(s) of size:%lld msg:(%s) pcifunc:0x%x\n",
55+
__get_str(dev), __entry->num_msgs, __entry->msg_size,
56+
otx2_mbox_id2name(__entry->id), __entry->pcifunc)
4857
);
4958

5059
TRACE_EVENT(otx2_msg_check,
@@ -81,18 +90,47 @@ TRACE_EVENT(otx2_msg_interrupt,
8190
);
8291

8392
TRACE_EVENT(otx2_msg_process,
84-
TP_PROTO(const struct pci_dev *pdev, u16 id, int err),
85-
TP_ARGS(pdev, id, err),
93+
TP_PROTO(const struct pci_dev *pdev, u16 id, int err, u16 pcifunc),
94+
TP_ARGS(pdev, id, err, pcifunc),
8695
TP_STRUCT__entry(__string(dev, pci_name(pdev))
8796
__field(u16, id)
8897
__field(int, err)
98+
__field(u16, pcifunc)
8999
),
90100
TP_fast_assign(__assign_str(dev);
91101
__entry->id = id;
92102
__entry->err = err;
103+
__entry->pcifunc = pcifunc;
104+
),
105+
TP_printk("[%s] msg:(%s) error:%d pcifunc:0x%x\n", __get_str(dev),
106+
otx2_mbox_id2name(__entry->id),
107+
__entry->err, __entry->pcifunc)
108+
);
109+
110+
TRACE_EVENT(otx2_msg_wait_rsp,
111+
TP_PROTO(const struct pci_dev *pdev),
112+
TP_ARGS(pdev),
113+
TP_STRUCT__entry(__string(dev, pci_name(pdev))
114+
),
115+
TP_fast_assign(__assign_str(dev)
116+
),
117+
TP_printk("[%s] timed out while waiting for response\n",
118+
__get_str(dev))
119+
);
120+
121+
TRACE_EVENT(otx2_msg_status,
122+
TP_PROTO(const struct pci_dev *pdev, const char *msg, u16 num_msgs),
123+
TP_ARGS(pdev, msg, num_msgs),
124+
TP_STRUCT__entry(__string(dev, pci_name(pdev))
125+
__string(str, msg)
126+
__field(u16, num_msgs)
127+
),
128+
TP_fast_assign(__assign_str(dev);
129+
__assign_str(str);
130+
__entry->num_msgs = num_msgs;
93131
),
94-
TP_printk("[%s] msg:(%s) error:%d\n", __get_str(dev),
95-
otx2_mbox_id2name(__entry->id), __entry->err)
132+
TP_printk("[%s] %s num_msgs:%d\n", __get_str(dev),
133+
__get_str(str), __entry->num_msgs)
96134
);
97135

98136
#endif /* __RVU_TRACE_H */

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@ static struct _req_type __maybe_unused \
871871
*otx2_mbox_alloc_msg_ ## _fn_name(struct mbox *mbox) \
872872
{ \
873873
struct _req_type *req; \
874+
u16 pcifunc = mbox->pfvf->pcifunc; \
874875
\
875876
req = (struct _req_type *)otx2_mbox_alloc_msg_rsp( \
876877
&mbox->mbox, 0, sizeof(struct _req_type), \
@@ -879,7 +880,8 @@ static struct _req_type __maybe_unused \
879880
return NULL; \
880881
req->hdr.sig = OTX2_MBOX_REQ_SIG; \
881882
req->hdr.id = _id; \
882-
trace_otx2_msg_alloc(mbox->mbox.pdev, _id, sizeof(*req)); \
883+
req->hdr.pcifunc = pcifunc; \
884+
trace_otx2_msg_alloc(mbox->mbox.pdev, _id, sizeof(*req), pcifunc); \
883885
return req; \
884886
}
885887

drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,9 @@ static void otx2_pfvf_mbox_handler(struct work_struct *work)
465465

466466
offset = ALIGN(sizeof(struct mbox_hdr), MBOX_MSG_ALIGN);
467467

468+
trace_otx2_msg_status(pf->pdev, "PF-VF down queue handler(forwarding)",
469+
vf_mbox->num_msgs);
470+
468471
for (id = 0; id < vf_mbox->num_msgs; id++) {
469472
msg = (struct mbox_msghdr *)(mdev->mbase + mbox->rx_start +
470473
offset);
@@ -473,7 +476,7 @@ static void otx2_pfvf_mbox_handler(struct work_struct *work)
473476
goto inval_msg;
474477

475478
/* Set VF's number in each of the msg */
476-
msg->pcifunc &= RVU_PFVF_FUNC_MASK;
479+
msg->pcifunc &= ~RVU_PFVF_FUNC_MASK;
477480
msg->pcifunc |= (vf_idx + 1) & RVU_PFVF_FUNC_MASK;
478481
offset = msg->next_msgoff;
479482
}
@@ -503,6 +506,9 @@ static void otx2_pfvf_mbox_up_handler(struct work_struct *work)
503506

504507
offset = mbox->rx_start + ALIGN(sizeof(struct mbox_hdr), MBOX_MSG_ALIGN);
505508

509+
trace_otx2_msg_status(pf->pdev, "PF-VF up queue handler(response)",
510+
vf_mbox->up_num_msgs);
511+
506512
for (id = 0; id < vf_mbox->up_num_msgs; id++) {
507513
msg = mdev->mbase + offset;
508514

@@ -819,6 +825,9 @@ static void otx2_pfaf_mbox_handler(struct work_struct *work)
819825
offset = mbox->rx_start + ALIGN(sizeof(*rsp_hdr), MBOX_MSG_ALIGN);
820826
pf = af_mbox->pfvf;
821827

828+
trace_otx2_msg_status(pf->pdev, "PF-AF down queue handler(response)",
829+
num_msgs);
830+
822831
for (id = 0; id < num_msgs; id++) {
823832
msg = (struct mbox_msghdr *)(mdev->mbase + offset);
824833
otx2_process_pfaf_mbox_msg(pf, msg);
@@ -974,6 +983,9 @@ static void otx2_pfaf_mbox_up_handler(struct work_struct *work)
974983

975984
offset = mbox->rx_start + ALIGN(sizeof(*rsp_hdr), MBOX_MSG_ALIGN);
976985

986+
trace_otx2_msg_status(pf->pdev, "PF-AF up queue handler(notification)",
987+
num_msgs);
988+
977989
for (id = 0; id < num_msgs; id++) {
978990
msg = (struct mbox_msghdr *)(mdev->mbase + offset);
979991

@@ -1023,6 +1035,9 @@ static irqreturn_t otx2_pfaf_mbox_intr_handler(int irq, void *pf_irq)
10231035

10241036
trace_otx2_msg_interrupt(pf->pdev, "UP message from AF to PF",
10251037
BIT_ULL(0));
1038+
1039+
trace_otx2_msg_status(pf->pdev, "PF-AF up work queued(interrupt)",
1040+
hdr->num_msgs);
10261041
}
10271042

10281043
if (mbox_data & MBOX_DOWN_MSG) {
@@ -1039,6 +1054,9 @@ static irqreturn_t otx2_pfaf_mbox_intr_handler(int irq, void *pf_irq)
10391054

10401055
trace_otx2_msg_interrupt(pf->pdev, "DOWN reply from AF to PF",
10411056
BIT_ULL(0));
1057+
1058+
trace_otx2_msg_status(pf->pdev, "PF-AF down work queued(interrupt)",
1059+
hdr->num_msgs);
10421060
}
10431061

10441062
return IRQ_HANDLED;
@@ -3285,6 +3303,7 @@ static void otx2_vf_link_event_task(struct work_struct *work)
32853303
req = (struct cgx_link_info_msg *)msghdr;
32863304
req->hdr.id = MBOX_MSG_CGX_LINK_EVENT;
32873305
req->hdr.sig = OTX2_MBOX_REQ_SIG;
3306+
req->hdr.pcifunc = pf->pcifunc;
32883307
memcpy(&req->link_info, &pf->linfo, sizeof(req->link_info));
32893308

32903309
otx2_mbox_wait_for_zero(&pf->mbox_pfvf[0].mbox_up, vf_idx);

drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static int otx2vf_process_mbox_msg_up(struct otx2_nic *vf,
136136

137137
rsp->hdr.id = MBOX_MSG_CGX_LINK_EVENT;
138138
rsp->hdr.sig = OTX2_MBOX_RSP_SIG;
139-
rsp->hdr.pcifunc = 0;
139+
rsp->hdr.pcifunc = req->pcifunc;
140140
rsp->hdr.rc = 0;
141141
err = otx2_mbox_up_handler_cgx_link_event(
142142
vf, (struct cgx_link_info_msg *)req, rsp);

0 commit comments

Comments
 (0)