net/ncsi/ncsi-rsp.c
Source file repositories/reference/linux-study-clean/net/ncsi/ncsi-rsp.c
File Facts
- System
- Linux kernel
- Corpus path
net/ncsi/ncsi-rsp.c- Extension
.c- Size
- 34787 bytes
- Lines
- 1273
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- 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/kernel.hlinux/init.hlinux/netdevice.hlinux/etherdevice.hlinux/skbuff.hnet/ncsi.hnet/net_namespace.hnet/sock.hnet/genetlink.hinternal.hncsi-pkt.hncsi-netlink.h
Detected Declarations
function fieldsfunction ncsi_validate_rsp_pktfunction ntohsfunction ncsi_rsp_handler_cisfunction ncsi_rsp_handler_spfunction ncsi_rsp_handler_dpfunction ncsi_rsp_handler_ecfunction ncsi_rsp_handler_dcfunction ncsi_rsp_handler_rcfunction ncsi_rsp_handler_ecntfunction ncsi_rsp_handler_dcntfunction ncsi_rsp_handler_aefunction ncsi_rsp_handler_slfunction ncsi_rsp_handler_glsfunction ncsi_rsp_handler_svffunction ncsi_rsp_handler_evfunction ncsi_rsp_handler_dvfunction ncsi_rsp_handler_smafunction ncsi_rsp_handler_ebffunction ncsi_rsp_handler_dbffunction ncsi_rsp_handler_egmffunction ncsi_rsp_handler_dgmffunction ncsi_rsp_handler_snfcfunction ncsi_rsp_handler_oem_gmafunction ncsi_rsp_handler_oem_mlxfunction ncsi_rsp_handler_oem_bcmfunction ncsi_rsp_handler_oem_intelfunction ncsi_rsp_handler_oemfunction ncsi_rsp_handler_gvifunction ncsi_rsp_handler_gcfunction ncsi_rsp_handler_gpfunction ncsi_rsp_handler_gcpsfunction ncsi_rsp_handler_gnsfunction ncsi_rsp_handler_gnptsfunction ncsi_rsp_handler_gpsfunction ncsi_rsp_handler_gpuuidfunction ncsi_rsp_handler_pldmfunction ncsi_rsp_handler_netlinkfunction ncsi_rsp_handler_gmcmafunction ncsi_rcv_rsp
Annotated Snippet
ntohs(h->reason) != NCSI_PKT_RSP_R_NO_ERROR) {
netdev_dbg(nr->ndp->ndev.dev,
"NCSI: non zero response/reason code %04xh, %04xh\n",
ntohs(h->code), ntohs(h->reason));
return -EPERM;
}
/* Validate checksum, which might be zeroes if the
* sender doesn't support checksum according to NCSI
* specification.
*/
pchecksum = (__be32 *)((void *)(h + 1) + ALIGN(payload, 4) - 4);
if (ntohl(*pchecksum) == 0)
return 0;
checksum = ncsi_calculate_checksum((unsigned char *)h,
sizeof(*h) + payload - 4);
if (*pchecksum != htonl(checksum)) {
netdev_dbg(nr->ndp->ndev.dev,
"NCSI: checksum mismatched; recd: %08x calc: %08x\n",
*pchecksum, htonl(checksum));
return -EINVAL;
}
return 0;
}
static int ncsi_rsp_handler_cis(struct ncsi_request *nr)
{
struct ncsi_rsp_pkt *rsp;
struct ncsi_dev_priv *ndp = nr->ndp;
struct ncsi_package *np;
struct ncsi_channel *nc;
unsigned char id;
rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp);
ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, &np, &nc);
if (!nc) {
if (ndp->flags & NCSI_DEV_PROBED)
return -ENXIO;
id = NCSI_CHANNEL_INDEX(rsp->rsp.common.channel);
nc = ncsi_add_channel(np, id);
}
return nc ? 0 : -ENODEV;
}
static int ncsi_rsp_handler_sp(struct ncsi_request *nr)
{
struct ncsi_rsp_pkt *rsp;
struct ncsi_dev_priv *ndp = nr->ndp;
struct ncsi_package *np;
unsigned char id;
/* Add the package if it's not existing. Otherwise,
* to change the state of its child channels.
*/
rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp);
ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel,
&np, NULL);
if (!np) {
if (ndp->flags & NCSI_DEV_PROBED)
return -ENXIO;
id = NCSI_PACKAGE_INDEX(rsp->rsp.common.channel);
np = ncsi_add_package(ndp, id);
if (!np)
return -ENODEV;
}
return 0;
}
static int ncsi_rsp_handler_dp(struct ncsi_request *nr)
{
struct ncsi_rsp_pkt *rsp;
struct ncsi_dev_priv *ndp = nr->ndp;
struct ncsi_package *np;
struct ncsi_channel *nc;
unsigned long flags;
/* Find the package */
rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp);
ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel,
&np, NULL);
if (!np)
return -ENODEV;
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/init.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/skbuff.h`, `net/ncsi.h`, `net/net_namespace.h`.
- Detected declarations: `function fields`, `function ncsi_validate_rsp_pkt`, `function ntohs`, `function ncsi_rsp_handler_cis`, `function ncsi_rsp_handler_sp`, `function ncsi_rsp_handler_dp`, `function ncsi_rsp_handler_ec`, `function ncsi_rsp_handler_dc`, `function ncsi_rsp_handler_rc`, `function ncsi_rsp_handler_ecnt`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source 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.