net/ncsi/ncsi-cmd.c
Source file repositories/reference/linux-study-clean/net/ncsi/ncsi-cmd.c
File Facts
- System
- Linux kernel
- Corpus path
net/ncsi/ncsi-cmd.c- Extension
.c- Size
- 10496 bytes
- Lines
- 409
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/kernel.hlinux/init.hlinux/etherdevice.hlinux/netdevice.hlinux/skbuff.hnet/ncsi.hnet/net_namespace.hnet/sock.hnet/genetlink.hinternal.hncsi-pkt.h
Detected Declarations
function ncsi_calculate_checksumfunction ncsi_cmd_build_headerfunction ncsi_cmd_handler_defaultfunction ncsi_cmd_handler_spfunction ncsi_cmd_handler_dcfunction ncsi_cmd_handler_rcfunction ncsi_cmd_handler_aefunction ncsi_cmd_handler_slfunction ncsi_cmd_handler_svffunction ncsi_cmd_handler_evfunction ncsi_cmd_handler_smafunction ncsi_cmd_handler_ebffunction ncsi_cmd_handler_egmffunction ncsi_cmd_handler_snfcfunction ncsi_cmd_handler_oemfunction ncsi_xmit_cmd
Annotated Snippet
if (ncsi_cmd_handlers[i].type == type) {
if (ncsi_cmd_handlers[i].handler)
nch = &ncsi_cmd_handlers[i];
else
nch = NULL;
break;
}
}
if (!nch) {
netdev_err(nca->ndp->ndev.dev,
"Cannot send packet with type 0x%02x\n", nca->type);
return -ENOENT;
}
/* Get packet payload length and allocate the request
* It is expected that if length set as negative in
* handler structure means caller is initializing it
* and setting length in nca before calling xmit function
*/
if (nch->payload >= 0)
nca->payload = nch->payload;
nr = ncsi_alloc_command(nca);
if (!nr)
return -ENOMEM;
/* track netlink information */
if (nca->req_flags == NCSI_REQ_FLAG_NETLINK_DRIVEN) {
nr->snd_seq = nca->info->snd_seq;
nr->snd_portid = nca->info->snd_portid;
nr->nlhdr = *nca->info->nlhdr;
}
/* Prepare the packet */
nca->id = nr->id;
ret = nch->handler(nr->cmd, nca);
if (ret) {
ncsi_free_request(nr);
return ret;
}
/* Fill the ethernet header */
eh = skb_push(nr->cmd, sizeof(*eh));
eh->h_proto = htons(ETH_P_NCSI);
eth_broadcast_addr(eh->h_dest);
/* If mac address received from device then use it for
* source address as unicast address else use broadcast
* address as source address
*/
if (nca->ndp->gma_flag == 1)
memcpy(eh->h_source, nca->ndp->ndev.dev->dev_addr, ETH_ALEN);
else
eth_broadcast_addr(eh->h_source);
/* Start the timer for the request that might not have
* corresponding response. Given NCSI is an internal
* connection a 1 second delay should be sufficient.
*/
nr->enabled = true;
mod_timer(&nr->timer, jiffies + 1 * HZ);
/* Send NCSI packet */
skb_get(nr->cmd);
ret = dev_queue_xmit(nr->cmd);
if (ret < 0) {
ncsi_free_request(nr);
return ret;
}
return 0;
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/init.h`, `linux/etherdevice.h`, `linux/netdevice.h`, `linux/skbuff.h`, `net/ncsi.h`, `net/net_namespace.h`.
- Detected declarations: `function ncsi_calculate_checksum`, `function ncsi_cmd_build_header`, `function ncsi_cmd_handler_default`, `function ncsi_cmd_handler_sp`, `function ncsi_cmd_handler_dc`, `function ncsi_cmd_handler_rc`, `function ncsi_cmd_handler_ae`, `function ncsi_cmd_handler_sl`, `function ncsi_cmd_handler_svf`, `function ncsi_cmd_handler_ev`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
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.