drivers/net/ethernet/marvell/octeontx2/af/mbox.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/octeontx2/af/mbox.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/octeontx2/af/mbox.c- Extension
.c- Size
- 13731 bytes
- Lines
- 570
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/interrupt.hlinux/pci.hrvu_reg.hcn20k/reg.hcn20k/api.hmbox.hrvu_trace.hrvu.h
Detected Declarations
function __otx2_mbox_resetfunction otx2_mbox_resetfunction otx2_mbox_destroyfunction cn20k_mbox_setupfunction otx2_mbox_setupfunction otx2_mbox_initfunction otx2_mbox_regions_initfunction otx2_mbox_wait_for_rspfunction otx2_mbox_busy_poll_for_rspfunction otx2_mbox_msg_send_datafunction otx2_mbox_msg_sendfunction otx2_mbox_msg_send_upfunction otx2_mbox_wait_for_zerofunction otx2_mbox_check_rsp_msgsfunction otx2_reply_invalid_msgfunction otx2_mbox_nonemptyexport __otx2_mbox_resetexport otx2_mbox_resetexport otx2_mbox_destroyexport otx2_mbox_initexport otx2_mbox_regions_initexport otx2_mbox_wait_for_rspexport otx2_mbox_busy_poll_for_rspexport otx2_mbox_msg_sendexport otx2_mbox_msg_send_upexport otx2_mbox_wait_for_zeroexport otx2_mbox_alloc_msg_rspexport otx2_mbox_get_rspexport otx2_mbox_check_rsp_msgsexport otx2_reply_invalid_msgexport otx2_mbox_nonemptyexport otx2_mbox_id2name
Annotated Snippet
if (msg == pmsg) {
if (pmsg->id != prsp->id)
goto error;
spin_unlock(&mdev->mbox_lock);
return prsp;
}
imsg = mbox->tx_start + pmsg->next_msgoff;
irsp = mbox->rx_start + prsp->next_msgoff;
}
error:
spin_unlock(&mdev->mbox_lock);
return ERR_PTR(-ENODEV);
}
EXPORT_SYMBOL(otx2_mbox_get_rsp);
int otx2_mbox_check_rsp_msgs(struct otx2_mbox *mbox, int devid)
{
unsigned long ireq = mbox->tx_start + msgs_offset;
unsigned long irsp = mbox->rx_start + msgs_offset;
struct otx2_mbox_dev *mdev = &mbox->dev[devid];
int rc = -ENODEV;
u16 msgs;
spin_lock(&mdev->mbox_lock);
if (mdev->num_msgs != mdev->msgs_acked)
goto exit;
for (msgs = 0; msgs < mdev->msgs_acked; msgs++) {
struct mbox_msghdr *preq = mdev->mbase + ireq;
struct mbox_msghdr *prsp = mdev->mbase + irsp;
if (preq->id != prsp->id) {
trace_otx2_msg_check(mbox->pdev, preq->id,
prsp->id, prsp->rc);
goto exit;
}
if (prsp->rc) {
rc = prsp->rc;
trace_otx2_msg_check(mbox->pdev, preq->id,
prsp->id, prsp->rc);
goto exit;
}
ireq = mbox->tx_start + preq->next_msgoff;
irsp = mbox->rx_start + prsp->next_msgoff;
}
rc = 0;
exit:
spin_unlock(&mdev->mbox_lock);
return rc;
}
EXPORT_SYMBOL(otx2_mbox_check_rsp_msgs);
int
otx2_reply_invalid_msg(struct otx2_mbox *mbox, int devid, u16 pcifunc, u16 id)
{
struct msg_rsp *rsp;
rsp = (struct msg_rsp *)
otx2_mbox_alloc_msg(mbox, devid, sizeof(*rsp));
if (!rsp)
return -ENOMEM;
rsp->hdr.id = id;
rsp->hdr.sig = OTX2_MBOX_RSP_SIG;
rsp->hdr.rc = MBOX_MSG_INVALID;
rsp->hdr.pcifunc = pcifunc;
return 0;
}
EXPORT_SYMBOL(otx2_reply_invalid_msg);
bool otx2_mbox_nonempty(struct otx2_mbox *mbox, int devid)
{
struct otx2_mbox_dev *mdev = &mbox->dev[devid];
bool ret;
spin_lock(&mdev->mbox_lock);
ret = mdev->num_msgs != 0;
spin_unlock(&mdev->mbox_lock);
return ret;
}
EXPORT_SYMBOL(otx2_mbox_nonempty);
const char *otx2_mbox_id2name(u16 id)
{
switch (id) {
#define M(_name, _id, _1, _2, _3) case _id: return # _name;
Annotation
- Immediate include surface: `linux/module.h`, `linux/interrupt.h`, `linux/pci.h`, `rvu_reg.h`, `cn20k/reg.h`, `cn20k/api.h`, `mbox.h`, `rvu_trace.h`.
- Detected declarations: `function __otx2_mbox_reset`, `function otx2_mbox_reset`, `function otx2_mbox_destroy`, `function cn20k_mbox_setup`, `function otx2_mbox_setup`, `function otx2_mbox_init`, `function otx2_mbox_regions_init`, `function otx2_mbox_wait_for_rsp`, `function otx2_mbox_busy_poll_for_rsp`, `function otx2_mbox_msg_send_data`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.