drivers/infiniband/hw/usnic/usnic_fwd.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/usnic/usnic_fwd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/usnic/usnic_fwd.c- Extension
.c- Size
- 8817 bytes
- Lines
- 358
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/netdevice.hlinux/pci.henic_api.husnic_common_pkt_hdr.husnic_fwd.husnic_log.h
Detected Declarations
function Copyrightfunction usnic_fwd_devcmdfunction usnic_fwd_dev_freefunction usnic_fwd_set_macfunction usnic_fwd_add_ipaddrfunction usnic_fwd_del_ipaddrfunction usnic_fwd_carrier_upfunction usnic_fwd_carrier_downfunction usnic_fwd_set_mtufunction usnic_fwd_dev_ready_lockedfunction validate_filter_lockedfunction fill_tlvfunction usnic_fwd_alloc_flowfunction usnic_fwd_dealloc_flowfunction usnic_fwd_enable_qpfunction usnic_fwd_disable_qp
Annotated Snippet
if (status == ERR_EINVAL && cmd == CMD_DEL_FILTER) {
usnic_dbg("Dev %s vnic idx %u cmd %u already deleted",
ufdev->name, vnic_idx, cmd);
} else {
usnic_err("Dev %s vnic idx %u cmd %u failed with status %d\n",
ufdev->name, vnic_idx, cmd,
status);
}
} else {
usnic_dbg("Dev %s vnic idx %u cmd %u success",
ufdev->name, vnic_idx, cmd);
}
return status;
}
static int usnic_fwd_devcmd(struct usnic_fwd_dev *ufdev, int vnic_idx,
enum vnic_devcmd_cmd cmd, u64 *a0, u64 *a1)
{
int status;
spin_lock(&ufdev->lock);
status = usnic_fwd_devcmd_locked(ufdev, vnic_idx, cmd, a0, a1);
spin_unlock(&ufdev->lock);
return status;
}
struct usnic_fwd_dev *usnic_fwd_dev_alloc(struct pci_dev *pdev)
{
struct usnic_fwd_dev *ufdev;
ufdev = kzalloc_obj(*ufdev);
if (!ufdev)
return NULL;
ufdev->pdev = pdev;
ufdev->netdev = pci_get_drvdata(pdev);
spin_lock_init(&ufdev->lock);
BUILD_BUG_ON(sizeof(ufdev->name) != sizeof(ufdev->netdev->name));
strscpy(ufdev->name, ufdev->netdev->name);
return ufdev;
}
void usnic_fwd_dev_free(struct usnic_fwd_dev *ufdev)
{
kfree(ufdev);
}
void usnic_fwd_set_mac(struct usnic_fwd_dev *ufdev, const char mac[ETH_ALEN])
{
spin_lock(&ufdev->lock);
memcpy(&ufdev->mac, mac, sizeof(ufdev->mac));
spin_unlock(&ufdev->lock);
}
void usnic_fwd_add_ipaddr(struct usnic_fwd_dev *ufdev, __be32 inaddr)
{
spin_lock(&ufdev->lock);
if (!ufdev->inaddr)
ufdev->inaddr = inaddr;
spin_unlock(&ufdev->lock);
}
void usnic_fwd_del_ipaddr(struct usnic_fwd_dev *ufdev)
{
spin_lock(&ufdev->lock);
ufdev->inaddr = 0;
spin_unlock(&ufdev->lock);
}
void usnic_fwd_carrier_up(struct usnic_fwd_dev *ufdev)
{
spin_lock(&ufdev->lock);
ufdev->link_up = 1;
spin_unlock(&ufdev->lock);
}
void usnic_fwd_carrier_down(struct usnic_fwd_dev *ufdev)
{
spin_lock(&ufdev->lock);
ufdev->link_up = 0;
spin_unlock(&ufdev->lock);
}
void usnic_fwd_set_mtu(struct usnic_fwd_dev *ufdev, unsigned int mtu)
{
spin_lock(&ufdev->lock);
ufdev->mtu = mtu;
Annotation
- Immediate include surface: `linux/netdevice.h`, `linux/pci.h`, `enic_api.h`, `usnic_common_pkt_hdr.h`, `usnic_fwd.h`, `usnic_log.h`.
- Detected declarations: `function Copyright`, `function usnic_fwd_devcmd`, `function usnic_fwd_dev_free`, `function usnic_fwd_set_mac`, `function usnic_fwd_add_ipaddr`, `function usnic_fwd_del_ipaddr`, `function usnic_fwd_carrier_up`, `function usnic_fwd_carrier_down`, `function usnic_fwd_set_mtu`, `function usnic_fwd_dev_ready_locked`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.