u32 ncsi_calculate_checksum(unsignedchar *data, int len)
{
u32 checksum = 0; int i;
for (i = 0; i < len; i += 2)
checksum += (((u32)data[i] << 8) | data[i + 1]);
checksum = (~checksum + 1); return checksum;
}
/* This function should be called after the data area has been *populatedcompletely.
*/ staticvoid ncsi_cmd_build_header(struct ncsi_pkt_hdr *h, struct ncsi_cmd_arg *nca)
{
u32 checksum;
__be32 *pchecksum;
int ncsi_xmit_cmd(struct ncsi_cmd_arg *nca)
{ struct ncsi_cmd_handler *nch = NULL; struct ncsi_request *nr; unsignedchar type; struct ethhdr *eh; int i, ret;
/* Use OEM generic handler for Netlink request */ if (nca->req_flags == NCSI_REQ_FLAG_NETLINK_DRIVEN)
type = NCSI_PKT_CMD_OEM; else
type = nca->type;
/* Search for the handler */ for (i = 0; i < ARRAY_SIZE(ncsi_cmd_handlers); i++) { 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 *Itisexpectedthatiflengthsetasnegativein *handlerstructuremeanscallerisinitializingit *andsettinglengthinncabeforecallingxmitfunction
*/ 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 *sourceaddressasunicastaddresselseusebroadcast *addressassourceaddress
*/ 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 *correspondingresponse.GivenNCSIisaninternal *connectiona1seconddelayshouldbesufficient.
*/
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;
}
return0;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet am 2026-09-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.