Lines Matching +full:nc +full:- +full:si
1 // SPDX-License-Identifier: GPL-2.0-or-later
19 #include "ncsi-pkt.h"
44 h->mc_id = 0; in ncsi_cmd_build_header()
45 h->revision = NCSI_PKT_REVISION; in ncsi_cmd_build_header()
46 h->reserved = 0; in ncsi_cmd_build_header()
47 h->id = nca->id; in ncsi_cmd_build_header()
48 h->type = nca->type; in ncsi_cmd_build_header()
49 h->channel = NCSI_TO_CHANNEL(nca->package, in ncsi_cmd_build_header()
50 nca->channel); in ncsi_cmd_build_header()
51 h->length = htons(nca->payload); in ncsi_cmd_build_header()
52 h->reserved1[0] = 0; in ncsi_cmd_build_header()
53 h->reserved1[1] = 0; in ncsi_cmd_build_header()
57 sizeof(*h) + nca->payload); in ncsi_cmd_build_header()
59 ALIGN(nca->payload, 4)); in ncsi_cmd_build_header()
69 ncsi_cmd_build_header(&cmd->cmd.common, nca); in ncsi_cmd_handler_default()
80 cmd->hw_arbitration = nca->bytes[0]; in ncsi_cmd_handler_sp()
81 ncsi_cmd_build_header(&cmd->cmd.common, nca); in ncsi_cmd_handler_sp()
92 cmd->ald = nca->bytes[0]; in ncsi_cmd_handler_dc()
93 ncsi_cmd_build_header(&cmd->cmd.common, nca); in ncsi_cmd_handler_dc()
104 ncsi_cmd_build_header(&cmd->cmd.common, nca); in ncsi_cmd_handler_rc()
115 cmd->mc_id = nca->bytes[0]; in ncsi_cmd_handler_ae()
116 cmd->mode = htonl(nca->dwords[1]); in ncsi_cmd_handler_ae()
117 ncsi_cmd_build_header(&cmd->cmd.common, nca); in ncsi_cmd_handler_ae()
128 cmd->mode = htonl(nca->dwords[0]); in ncsi_cmd_handler_sl()
129 cmd->oem_mode = htonl(nca->dwords[1]); in ncsi_cmd_handler_sl()
130 ncsi_cmd_build_header(&cmd->cmd.common, nca); in ncsi_cmd_handler_sl()
141 cmd->vlan = htons(nca->words[1]); in ncsi_cmd_handler_svf()
142 cmd->index = nca->bytes[6]; in ncsi_cmd_handler_svf()
143 cmd->enable = nca->bytes[7]; in ncsi_cmd_handler_svf()
144 ncsi_cmd_build_header(&cmd->cmd.common, nca); in ncsi_cmd_handler_svf()
155 cmd->mode = nca->bytes[3]; in ncsi_cmd_handler_ev()
156 ncsi_cmd_build_header(&cmd->cmd.common, nca); in ncsi_cmd_handler_ev()
169 cmd->mac[i] = nca->bytes[i]; in ncsi_cmd_handler_sma()
170 cmd->index = nca->bytes[6]; in ncsi_cmd_handler_sma()
171 cmd->at_e = nca->bytes[7]; in ncsi_cmd_handler_sma()
172 ncsi_cmd_build_header(&cmd->cmd.common, nca); in ncsi_cmd_handler_sma()
183 cmd->mode = htonl(nca->dwords[0]); in ncsi_cmd_handler_ebf()
184 ncsi_cmd_build_header(&cmd->cmd.common, nca); in ncsi_cmd_handler_ebf()
195 cmd->mode = htonl(nca->dwords[0]); in ncsi_cmd_handler_egmf()
196 ncsi_cmd_build_header(&cmd->cmd.common, nca); in ncsi_cmd_handler_egmf()
207 cmd->mode = nca->bytes[0]; in ncsi_cmd_handler_snfc()
208 ncsi_cmd_build_header(&cmd->cmd.common, nca); in ncsi_cmd_handler_snfc()
219 /* NC-SI spec DSP_0222_1.2.0, section 8.2.2.2 in ncsi_cmd_handler_oem()
221 * 32-bit boundary before the checksum field. in ncsi_cmd_handler_oem()
226 payload = ALIGN(nca->payload, 4); in ncsi_cmd_handler_oem()
231 unsafe_memcpy(&cmd->mfr_id, nca->data, nca->payload, in ncsi_cmd_handler_oem()
233 ncsi_cmd_build_header(&cmd->cmd.common, nca); in ncsi_cmd_handler_oem()
271 { NCSI_PKT_CMD_OEM, -1, ncsi_cmd_handler_oem },
279 struct ncsi_dev_priv *ndp = nca->ndp; in ncsi_alloc_command()
280 struct ncsi_dev *nd = &ndp->ndev; in ncsi_alloc_command()
281 struct net_device *dev = nd->dev; in ncsi_alloc_command()
283 int tlen = dev->needed_tailroom; in ncsi_alloc_command()
289 nr = ncsi_alloc_request(ndp, nca->req_flags); in ncsi_alloc_command()
293 /* NCSI command packet has 16-bytes header, payload, 4 bytes checksum. in ncsi_alloc_command()
295 * aligned to 32-bit boundary. in ncsi_alloc_command()
300 payload = ALIGN(nca->payload, 4); in ncsi_alloc_command()
310 nr->cmd = skb; in ncsi_alloc_command()
314 skb->dev = dev; in ncsi_alloc_command()
315 skb->protocol = htons(ETH_P_NCSI); in ncsi_alloc_command()
329 if (nca->req_flags == NCSI_REQ_FLAG_NETLINK_DRIVEN) in ncsi_xmit_cmd()
332 type = nca->type; in ncsi_xmit_cmd()
347 netdev_err(nca->ndp->ndev.dev, in ncsi_xmit_cmd()
348 "Cannot send packet with type 0x%02x\n", nca->type); in ncsi_xmit_cmd()
349 return -ENOENT; in ncsi_xmit_cmd()
357 if (nch->payload >= 0) in ncsi_xmit_cmd()
358 nca->payload = nch->payload; in ncsi_xmit_cmd()
361 return -ENOMEM; in ncsi_xmit_cmd()
364 if (nca->req_flags == NCSI_REQ_FLAG_NETLINK_DRIVEN) { in ncsi_xmit_cmd()
365 nr->snd_seq = nca->info->snd_seq; in ncsi_xmit_cmd()
366 nr->snd_portid = nca->info->snd_portid; in ncsi_xmit_cmd()
367 nr->nlhdr = *nca->info->nlhdr; in ncsi_xmit_cmd()
371 nca->id = nr->id; in ncsi_xmit_cmd()
372 ret = nch->handler(nr->cmd, nca); in ncsi_xmit_cmd()
379 eh = skb_push(nr->cmd, sizeof(*eh)); in ncsi_xmit_cmd()
380 eh->h_proto = htons(ETH_P_NCSI); in ncsi_xmit_cmd()
381 eth_broadcast_addr(eh->h_dest); in ncsi_xmit_cmd()
387 if (nca->ndp->gma_flag == 1) in ncsi_xmit_cmd()
388 memcpy(eh->h_source, nca->ndp->ndev.dev->dev_addr, ETH_ALEN); in ncsi_xmit_cmd()
390 eth_broadcast_addr(eh->h_source); in ncsi_xmit_cmd()
396 nr->enabled = true; in ncsi_xmit_cmd()
397 mod_timer(&nr->timer, jiffies + 1 * HZ); in ncsi_xmit_cmd()
400 skb_get(nr->cmd); in ncsi_xmit_cmd()
401 ret = dev_queue_xmit(nr->cmd); in ncsi_xmit_cmd()