Lines Matching +full:common +full:- +full:mode +full:- +full:channel
1 // SPDX-License-Identifier: GPL-2.0-or-later
19 #include "ncsi-pkt.h"
20 #include "ncsi-netlink.h"
46 h = (struct ncsi_rsp_pkt_hdr *)skb_network_header(nr->rsp); in ncsi_validate_rsp_pkt()
48 if (h->common.revision != NCSI_PKT_REVISION) { in ncsi_validate_rsp_pkt()
49 netdev_dbg(nr->ndp->ndev.dev, in ncsi_validate_rsp_pkt()
51 return -EINVAL; in ncsi_validate_rsp_pkt()
53 if (ntohs(h->common.length) != payload) { in ncsi_validate_rsp_pkt()
54 netdev_dbg(nr->ndp->ndev.dev, in ncsi_validate_rsp_pkt()
56 return -EINVAL; in ncsi_validate_rsp_pkt()
60 if (ntohs(h->code) != NCSI_PKT_RSP_C_COMPLETED || in ncsi_validate_rsp_pkt()
61 ntohs(h->reason) != NCSI_PKT_RSP_R_NO_ERROR) { in ncsi_validate_rsp_pkt()
62 netdev_dbg(nr->ndp->ndev.dev, in ncsi_validate_rsp_pkt()
64 ntohs(h->code), ntohs(h->reason)); in ncsi_validate_rsp_pkt()
65 return -EPERM; in ncsi_validate_rsp_pkt()
72 pchecksum = (__be32 *)((void *)(h + 1) + ALIGN(payload, 4) - 4); in ncsi_validate_rsp_pkt()
77 sizeof(*h) + payload - 4); in ncsi_validate_rsp_pkt()
80 netdev_dbg(nr->ndp->ndev.dev, in ncsi_validate_rsp_pkt()
83 return -EINVAL; in ncsi_validate_rsp_pkt()
92 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_cis()
97 rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_cis()
98 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, &np, &nc); in ncsi_rsp_handler_cis()
100 if (ndp->flags & NCSI_DEV_PROBED) in ncsi_rsp_handler_cis()
101 return -ENXIO; in ncsi_rsp_handler_cis()
103 id = NCSI_CHANNEL_INDEX(rsp->rsp.common.channel); in ncsi_rsp_handler_cis()
107 return nc ? 0 : -ENODEV; in ncsi_rsp_handler_cis()
113 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_sp()
120 rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_sp()
121 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_sp()
124 if (ndp->flags & NCSI_DEV_PROBED) in ncsi_rsp_handler_sp()
125 return -ENXIO; in ncsi_rsp_handler_sp()
127 id = NCSI_PACKAGE_INDEX(rsp->rsp.common.channel); in ncsi_rsp_handler_sp()
130 return -ENODEV; in ncsi_rsp_handler_sp()
139 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_dp()
145 rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_dp()
146 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_dp()
149 return -ENODEV; in ncsi_rsp_handler_dp()
153 spin_lock_irqsave(&nc->lock, flags); in ncsi_rsp_handler_dp()
154 nc->state = NCSI_CHANNEL_INACTIVE; in ncsi_rsp_handler_dp()
155 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_rsp_handler_dp()
164 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_ec()
168 /* Find the package and channel */ in ncsi_rsp_handler_ec()
169 rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_ec()
170 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_ec()
173 return -ENODEV; in ncsi_rsp_handler_ec()
175 ncm = &nc->modes[NCSI_MODE_ENABLE]; in ncsi_rsp_handler_ec()
176 if (ncm->enable) in ncsi_rsp_handler_ec()
179 ncm->enable = 1; in ncsi_rsp_handler_ec()
186 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_dc()
195 /* Find the package and channel */ in ncsi_rsp_handler_dc()
196 rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_dc()
197 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_dc()
200 return -ENODEV; in ncsi_rsp_handler_dc()
202 ncm = &nc->modes[NCSI_MODE_ENABLE]; in ncsi_rsp_handler_dc()
203 if (!ncm->enable) in ncsi_rsp_handler_dc()
206 ncm->enable = 0; in ncsi_rsp_handler_dc()
213 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_rc()
217 /* Find the package and channel */ in ncsi_rsp_handler_rc()
218 rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_rc()
219 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_rc()
222 return -ENODEV; in ncsi_rsp_handler_rc()
224 /* Update state for the specified channel */ in ncsi_rsp_handler_rc()
225 spin_lock_irqsave(&nc->lock, flags); in ncsi_rsp_handler_rc()
226 nc->state = NCSI_CHANNEL_INACTIVE; in ncsi_rsp_handler_rc()
227 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_rsp_handler_rc()
235 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_ecnt()
239 /* Find the package and channel */ in ncsi_rsp_handler_ecnt()
240 rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_ecnt()
241 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_ecnt()
244 return -ENODEV; in ncsi_rsp_handler_ecnt()
246 ncm = &nc->modes[NCSI_MODE_TX_ENABLE]; in ncsi_rsp_handler_ecnt()
247 if (ncm->enable) in ncsi_rsp_handler_ecnt()
250 ncm->enable = 1; in ncsi_rsp_handler_ecnt()
257 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_dcnt()
261 /* Find the package and channel */ in ncsi_rsp_handler_dcnt()
262 rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_dcnt()
263 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_dcnt()
266 return -ENODEV; in ncsi_rsp_handler_dcnt()
268 ncm = &nc->modes[NCSI_MODE_TX_ENABLE]; in ncsi_rsp_handler_dcnt()
269 if (!ncm->enable) in ncsi_rsp_handler_dcnt()
272 ncm->enable = 0; in ncsi_rsp_handler_dcnt()
280 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_ae()
284 /* Find the package and channel */ in ncsi_rsp_handler_ae()
285 rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_ae()
286 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_ae()
289 return -ENODEV; in ncsi_rsp_handler_ae()
292 ncm = &nc->modes[NCSI_MODE_AEN]; in ncsi_rsp_handler_ae()
293 if (ncm->enable) in ncsi_rsp_handler_ae()
297 cmd = (struct ncsi_cmd_ae_pkt *)skb_network_header(nr->cmd); in ncsi_rsp_handler_ae()
298 ncm->enable = 1; in ncsi_rsp_handler_ae()
299 ncm->data[0] = cmd->mc_id; in ncsi_rsp_handler_ae()
300 ncm->data[1] = ntohl(cmd->mode); in ncsi_rsp_handler_ae()
309 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_sl()
313 /* Find the package and channel */ in ncsi_rsp_handler_sl()
314 rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_sl()
315 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_sl()
318 return -ENODEV; in ncsi_rsp_handler_sl()
320 cmd = (struct ncsi_cmd_sl_pkt *)skb_network_header(nr->cmd); in ncsi_rsp_handler_sl()
321 ncm = &nc->modes[NCSI_MODE_LINK]; in ncsi_rsp_handler_sl()
322 ncm->data[0] = ntohl(cmd->mode); in ncsi_rsp_handler_sl()
323 ncm->data[1] = ntohl(cmd->oem_mode); in ncsi_rsp_handler_sl()
331 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_gls()
336 /* Find the package and channel */ in ncsi_rsp_handler_gls()
337 rsp = (struct ncsi_rsp_gls_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_gls()
338 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_gls()
341 return -ENODEV; in ncsi_rsp_handler_gls()
343 ncm = &nc->modes[NCSI_MODE_LINK]; in ncsi_rsp_handler_gls()
344 ncm->data[2] = ntohl(rsp->status); in ncsi_rsp_handler_gls()
345 ncm->data[3] = ntohl(rsp->other); in ncsi_rsp_handler_gls()
346 ncm->data[4] = ntohl(rsp->oem_status); in ncsi_rsp_handler_gls()
348 if (nr->flags & NCSI_REQ_FLAG_EVENT_DRIVEN) in ncsi_rsp_handler_gls()
351 /* Reset the channel monitor if it has been enabled */ in ncsi_rsp_handler_gls()
352 spin_lock_irqsave(&nc->lock, flags); in ncsi_rsp_handler_gls()
353 nc->monitor.state = NCSI_CHANNEL_MONITOR_START; in ncsi_rsp_handler_gls()
354 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_rsp_handler_gls()
363 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_svf()
369 /* Find the package and channel */ in ncsi_rsp_handler_svf()
370 rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_svf()
371 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_svf()
374 return -ENODEV; in ncsi_rsp_handler_svf()
376 cmd = (struct ncsi_cmd_svf_pkt *)skb_network_header(nr->cmd); in ncsi_rsp_handler_svf()
377 ncf = &nc->vlan_filter; in ncsi_rsp_handler_svf()
378 if (cmd->index == 0 || cmd->index > ncf->n_vids) in ncsi_rsp_handler_svf()
379 return -ERANGE; in ncsi_rsp_handler_svf()
382 spin_lock_irqsave(&nc->lock, flags); in ncsi_rsp_handler_svf()
383 bitmap = &ncf->bitmap; in ncsi_rsp_handler_svf()
384 if (!(cmd->enable & 0x1)) { in ncsi_rsp_handler_svf()
385 if (test_and_clear_bit(cmd->index - 1, bitmap)) in ncsi_rsp_handler_svf()
386 ncf->vids[cmd->index - 1] = 0; in ncsi_rsp_handler_svf()
388 set_bit(cmd->index - 1, bitmap); in ncsi_rsp_handler_svf()
389 ncf->vids[cmd->index - 1] = ntohs(cmd->vlan); in ncsi_rsp_handler_svf()
391 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_rsp_handler_svf()
400 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_ev()
404 /* Find the package and channel */ in ncsi_rsp_handler_ev()
405 rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_ev()
406 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_ev()
409 return -ENODEV; in ncsi_rsp_handler_ev()
411 /* Check if VLAN mode has been enabled */ in ncsi_rsp_handler_ev()
412 ncm = &nc->modes[NCSI_MODE_VLAN]; in ncsi_rsp_handler_ev()
413 if (ncm->enable) in ncsi_rsp_handler_ev()
416 /* Update to VLAN mode */ in ncsi_rsp_handler_ev()
417 cmd = (struct ncsi_cmd_ev_pkt *)skb_network_header(nr->cmd); in ncsi_rsp_handler_ev()
418 ncm->enable = 1; in ncsi_rsp_handler_ev()
419 ncm->data[0] = ntohl((__force __be32)cmd->mode); in ncsi_rsp_handler_ev()
427 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_dv()
431 /* Find the package and channel */ in ncsi_rsp_handler_dv()
432 rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_dv()
433 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_dv()
436 return -ENODEV; in ncsi_rsp_handler_dv()
438 /* Check if VLAN mode has been enabled */ in ncsi_rsp_handler_dv()
439 ncm = &nc->modes[NCSI_MODE_VLAN]; in ncsi_rsp_handler_dv()
440 if (!ncm->enable) in ncsi_rsp_handler_dv()
443 /* Update to VLAN mode */ in ncsi_rsp_handler_dv()
444 ncm->enable = 0; in ncsi_rsp_handler_dv()
452 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_sma()
461 /* Find the package and channel */ in ncsi_rsp_handler_sma()
462 rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_sma()
463 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_sma()
466 return -ENODEV; in ncsi_rsp_handler_sma()
471 cmd = (struct ncsi_cmd_sma_pkt *)skb_network_header(nr->cmd); in ncsi_rsp_handler_sma()
472 enabled = cmd->at_e & 0x1; in ncsi_rsp_handler_sma()
473 ncf = &nc->mac_filter; in ncsi_rsp_handler_sma()
474 bitmap = &ncf->bitmap; in ncsi_rsp_handler_sma()
476 if (cmd->index == 0 || in ncsi_rsp_handler_sma()
477 cmd->index > ncf->n_uc + ncf->n_mc + ncf->n_mixed) in ncsi_rsp_handler_sma()
478 return -ERANGE; in ncsi_rsp_handler_sma()
480 index = (cmd->index - 1) * ETH_ALEN; in ncsi_rsp_handler_sma()
481 spin_lock_irqsave(&nc->lock, flags); in ncsi_rsp_handler_sma()
483 set_bit(cmd->index - 1, bitmap); in ncsi_rsp_handler_sma()
484 memcpy(&ncf->addrs[index], cmd->mac, ETH_ALEN); in ncsi_rsp_handler_sma()
486 clear_bit(cmd->index - 1, bitmap); in ncsi_rsp_handler_sma()
487 eth_zero_addr(&ncf->addrs[index]); in ncsi_rsp_handler_sma()
489 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_rsp_handler_sma()
498 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_ebf()
502 /* Find the package and channel */ in ncsi_rsp_handler_ebf()
503 rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_ebf()
504 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, NULL, &nc); in ncsi_rsp_handler_ebf()
506 return -ENODEV; in ncsi_rsp_handler_ebf()
509 ncm = &nc->modes[NCSI_MODE_BC]; in ncsi_rsp_handler_ebf()
510 if (ncm->enable) in ncsi_rsp_handler_ebf()
513 /* Update to broadcast filter mode */ in ncsi_rsp_handler_ebf()
514 cmd = (struct ncsi_cmd_ebf_pkt *)skb_network_header(nr->cmd); in ncsi_rsp_handler_ebf()
515 ncm->enable = 1; in ncsi_rsp_handler_ebf()
516 ncm->data[0] = ntohl(cmd->mode); in ncsi_rsp_handler_ebf()
524 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_dbf()
528 rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_dbf()
529 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_dbf()
532 return -ENODEV; in ncsi_rsp_handler_dbf()
535 ncm = &nc->modes[NCSI_MODE_BC]; in ncsi_rsp_handler_dbf()
536 if (!ncm->enable) in ncsi_rsp_handler_dbf()
539 /* Update to broadcast filter mode */ in ncsi_rsp_handler_dbf()
540 ncm->enable = 0; in ncsi_rsp_handler_dbf()
541 ncm->data[0] = 0; in ncsi_rsp_handler_dbf()
550 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_egmf()
554 /* Find the channel */ in ncsi_rsp_handler_egmf()
555 rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_egmf()
556 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_egmf()
559 return -ENODEV; in ncsi_rsp_handler_egmf()
562 ncm = &nc->modes[NCSI_MODE_MC]; in ncsi_rsp_handler_egmf()
563 if (ncm->enable) in ncsi_rsp_handler_egmf()
566 /* Update to multicast filter mode */ in ncsi_rsp_handler_egmf()
567 cmd = (struct ncsi_cmd_egmf_pkt *)skb_network_header(nr->cmd); in ncsi_rsp_handler_egmf()
568 ncm->enable = 1; in ncsi_rsp_handler_egmf()
569 ncm->data[0] = ntohl(cmd->mode); in ncsi_rsp_handler_egmf()
577 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_dgmf()
581 rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_dgmf()
582 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_dgmf()
585 return -ENODEV; in ncsi_rsp_handler_dgmf()
588 ncm = &nc->modes[NCSI_MODE_MC]; in ncsi_rsp_handler_dgmf()
589 if (!ncm->enable) in ncsi_rsp_handler_dgmf()
592 /* Update to multicast filter mode */ in ncsi_rsp_handler_dgmf()
593 ncm->enable = 0; in ncsi_rsp_handler_dgmf()
594 ncm->data[0] = 0; in ncsi_rsp_handler_dgmf()
603 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_snfc()
607 /* Find the channel */ in ncsi_rsp_handler_snfc()
608 rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_snfc()
609 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_snfc()
612 return -ENODEV; in ncsi_rsp_handler_snfc()
615 ncm = &nc->modes[NCSI_MODE_FC]; in ncsi_rsp_handler_snfc()
616 if (ncm->enable) in ncsi_rsp_handler_snfc()
619 /* Update to flow control mode */ in ncsi_rsp_handler_snfc()
620 cmd = (struct ncsi_cmd_snfc_pkt *)skb_network_header(nr->cmd); in ncsi_rsp_handler_snfc()
621 ncm->enable = 1; in ncsi_rsp_handler_snfc()
622 ncm->data[0] = cmd->mode; in ncsi_rsp_handler_snfc()
630 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_oem_gma()
631 struct net_device *ndev = ndp->ndev.dev; in ncsi_rsp_handler_oem_gma()
638 rsp = (struct ncsi_rsp_oem_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_oem_gma()
640 saddr.sa_family = ndev->type; in ncsi_rsp_handler_oem_gma()
641 ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE; in ncsi_rsp_handler_oem_gma()
649 memcpy(saddr.sa_data, &rsp->data[mac_addr_off], ETH_ALEN); in ncsi_rsp_handler_oem_gma()
653 return -ENXIO; in ncsi_rsp_handler_oem_gma()
656 ndp->gma_flag = 1; in ncsi_rsp_handler_oem_gma()
674 rsp = (struct ncsi_rsp_oem_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_oem_mlx()
675 mlx = (struct ncsi_rsp_oem_mlx_pkt *)(rsp->data); in ncsi_rsp_handler_oem_mlx()
677 if (mlx->cmd == NCSI_OEM_MLX_CMD_GMA && in ncsi_rsp_handler_oem_mlx()
678 mlx->param == NCSI_OEM_MLX_CMD_GMA_PARAM) in ncsi_rsp_handler_oem_mlx()
690 rsp = (struct ncsi_rsp_oem_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_oem_bcm()
691 bcm = (struct ncsi_rsp_oem_bcm_pkt *)(rsp->data); in ncsi_rsp_handler_oem_bcm()
693 if (bcm->type == NCSI_OEM_BCM_CMD_GMA) in ncsi_rsp_handler_oem_bcm()
705 rsp = (struct ncsi_rsp_oem_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_oem_intel()
706 intel = (struct ncsi_rsp_oem_intel_pkt *)(rsp->data); in ncsi_rsp_handler_oem_intel()
708 if (intel->cmd == NCSI_OEM_INTEL_CMD_GMA) in ncsi_rsp_handler_oem_intel()
731 rsp = (struct ncsi_rsp_oem_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_oem()
732 mfr_id = ntohl(rsp->mfr_id); in ncsi_rsp_handler_oem()
747 netdev_err(nr->ndp->ndev.dev, "Received unrecognized OEM packet with MFR-ID (0x%x)\n", in ncsi_rsp_handler_oem()
749 return -ENOENT; in ncsi_rsp_handler_oem()
753 return nrh->handler(nr); in ncsi_rsp_handler_oem()
759 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_gvi()
764 /* Find the channel */ in ncsi_rsp_handler_gvi()
765 rsp = (struct ncsi_rsp_gvi_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_gvi()
766 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_gvi()
769 return -ENODEV; in ncsi_rsp_handler_gvi()
771 /* Update channel's version info in ncsi_rsp_handler_gvi()
776 * Alpha1 and alpha2 are ISO/IEC 8859-1 characters. in ncsi_rsp_handler_gvi()
778 ncv = &nc->version; in ncsi_rsp_handler_gvi()
779 ncv->major = decode_bcd_u8(rsp->major); in ncsi_rsp_handler_gvi()
780 ncv->minor = decode_bcd_u8(rsp->minor); in ncsi_rsp_handler_gvi()
781 ncv->update = decode_bcd_u8(rsp->update); in ncsi_rsp_handler_gvi()
782 ncv->alpha1 = rsp->alpha1; in ncsi_rsp_handler_gvi()
783 ncv->alpha2 = rsp->alpha2; in ncsi_rsp_handler_gvi()
784 memcpy(ncv->fw_name, rsp->fw_name, 12); in ncsi_rsp_handler_gvi()
785 ncv->fw_version = ntohl(rsp->fw_version); in ncsi_rsp_handler_gvi()
786 for (i = 0; i < ARRAY_SIZE(ncv->pci_ids); i++) in ncsi_rsp_handler_gvi()
787 ncv->pci_ids[i] = ntohs(rsp->pci_ids[i]); in ncsi_rsp_handler_gvi()
788 ncv->mf_id = ntohl(rsp->mf_id); in ncsi_rsp_handler_gvi()
796 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_gc()
801 /* Find the channel */ in ncsi_rsp_handler_gc()
802 rsp = (struct ncsi_rsp_gc_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_gc()
803 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_gc()
806 return -ENODEV; in ncsi_rsp_handler_gc()
808 /* Update channel's capabilities */ in ncsi_rsp_handler_gc()
809 nc->caps[NCSI_CAP_GENERIC].cap = ntohl(rsp->cap) & in ncsi_rsp_handler_gc()
811 nc->caps[NCSI_CAP_BC].cap = ntohl(rsp->bc_cap) & in ncsi_rsp_handler_gc()
813 nc->caps[NCSI_CAP_MC].cap = ntohl(rsp->mc_cap) & in ncsi_rsp_handler_gc()
815 nc->caps[NCSI_CAP_BUFFER].cap = ntohl(rsp->buf_cap); in ncsi_rsp_handler_gc()
816 nc->caps[NCSI_CAP_AEN].cap = ntohl(rsp->aen_cap) & in ncsi_rsp_handler_gc()
818 nc->caps[NCSI_CAP_VLAN].cap = rsp->vlan_mode & in ncsi_rsp_handler_gc()
821 size = (rsp->uc_cnt + rsp->mc_cnt + rsp->mixed_cnt) * ETH_ALEN; in ncsi_rsp_handler_gc()
822 nc->mac_filter.addrs = kzalloc(size, GFP_ATOMIC); in ncsi_rsp_handler_gc()
823 if (!nc->mac_filter.addrs) in ncsi_rsp_handler_gc()
824 return -ENOMEM; in ncsi_rsp_handler_gc()
825 nc->mac_filter.n_uc = rsp->uc_cnt; in ncsi_rsp_handler_gc()
826 nc->mac_filter.n_mc = rsp->mc_cnt; in ncsi_rsp_handler_gc()
827 nc->mac_filter.n_mixed = rsp->mixed_cnt; in ncsi_rsp_handler_gc()
829 nc->vlan_filter.vids = kcalloc(rsp->vlan_cnt, in ncsi_rsp_handler_gc()
830 sizeof(*nc->vlan_filter.vids), in ncsi_rsp_handler_gc()
832 if (!nc->vlan_filter.vids) in ncsi_rsp_handler_gc()
833 return -ENOMEM; in ncsi_rsp_handler_gc()
837 nc->vlan_filter.bitmap = U64_MAX; in ncsi_rsp_handler_gc()
838 nc->vlan_filter.n_vids = rsp->vlan_cnt; in ncsi_rsp_handler_gc()
839 np->ndp->channel_count = rsp->channel_cnt; in ncsi_rsp_handler_gc()
848 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_gp()
857 /* Find the channel */ in ncsi_rsp_handler_gp()
858 rsp = (struct ncsi_rsp_gp_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_gp()
859 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_gp()
862 return -ENODEV; in ncsi_rsp_handler_gp()
865 if (ntohl(rsp->valid_modes) & 0x1) { /* BC filter mode */ in ncsi_rsp_handler_gp()
866 nc->modes[NCSI_MODE_BC].enable = 1; in ncsi_rsp_handler_gp()
867 nc->modes[NCSI_MODE_BC].data[0] = ntohl(rsp->bc_mode); in ncsi_rsp_handler_gp()
869 if (ntohl(rsp->valid_modes) & 0x2) /* Channel enabled */ in ncsi_rsp_handler_gp()
870 nc->modes[NCSI_MODE_ENABLE].enable = 1; in ncsi_rsp_handler_gp()
871 if (ntohl(rsp->valid_modes) & 0x4) /* Channel Tx enabled */ in ncsi_rsp_handler_gp()
872 nc->modes[NCSI_MODE_TX_ENABLE].enable = 1; in ncsi_rsp_handler_gp()
873 if (ntohl(rsp->valid_modes) & 0x8) /* MC filter mode */ in ncsi_rsp_handler_gp()
874 nc->modes[NCSI_MODE_MC].enable = 1; in ncsi_rsp_handler_gp()
877 nc->modes[NCSI_MODE_LINK].enable = 1; in ncsi_rsp_handler_gp()
878 nc->modes[NCSI_MODE_LINK].data[0] = ntohl(rsp->link_mode); in ncsi_rsp_handler_gp()
879 nc->modes[NCSI_MODE_VLAN].enable = 1; in ncsi_rsp_handler_gp()
880 nc->modes[NCSI_MODE_VLAN].data[0] = rsp->vlan_mode; in ncsi_rsp_handler_gp()
881 nc->modes[NCSI_MODE_FC].enable = 1; in ncsi_rsp_handler_gp()
882 nc->modes[NCSI_MODE_FC].data[0] = rsp->fc_mode; in ncsi_rsp_handler_gp()
883 nc->modes[NCSI_MODE_AEN].enable = 1; in ncsi_rsp_handler_gp()
884 nc->modes[NCSI_MODE_AEN].data[0] = ntohl(rsp->aen_mode); in ncsi_rsp_handler_gp()
888 enable = rsp->mac_enable; in ncsi_rsp_handler_gp()
889 ncmf = &nc->mac_filter; in ncsi_rsp_handler_gp()
890 spin_lock_irqsave(&nc->lock, flags); in ncsi_rsp_handler_gp()
891 bitmap = &ncmf->bitmap; in ncsi_rsp_handler_gp()
892 for (i = 0; i < rsp->mac_cnt; i++, pdata += 6) { in ncsi_rsp_handler_gp()
898 memcpy(&ncmf->addrs[i * ETH_ALEN], pdata, ETH_ALEN); in ncsi_rsp_handler_gp()
900 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_rsp_handler_gp()
903 enable = ntohs(rsp->vlan_enable); in ncsi_rsp_handler_gp()
904 ncvf = &nc->vlan_filter; in ncsi_rsp_handler_gp()
905 bitmap = &ncvf->bitmap; in ncsi_rsp_handler_gp()
906 spin_lock_irqsave(&nc->lock, flags); in ncsi_rsp_handler_gp()
907 for (i = 0; i < rsp->vlan_cnt; i++, pdata += 2) { in ncsi_rsp_handler_gp()
913 ncvf->vids[i] = ntohs(*(__be16 *)pdata); in ncsi_rsp_handler_gp()
915 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_rsp_handler_gp()
923 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_gcps()
927 /* Find the channel */ in ncsi_rsp_handler_gcps()
928 rsp = (struct ncsi_rsp_gcps_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_gcps()
929 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_gcps()
932 return -ENODEV; in ncsi_rsp_handler_gcps()
935 ncs = &nc->stats; in ncsi_rsp_handler_gcps()
936 ncs->hnc_cnt_hi = ntohl(rsp->cnt_hi); in ncsi_rsp_handler_gcps()
937 ncs->hnc_cnt_lo = ntohl(rsp->cnt_lo); in ncsi_rsp_handler_gcps()
938 ncs->hnc_rx_bytes = ntohl(rsp->rx_bytes); in ncsi_rsp_handler_gcps()
939 ncs->hnc_tx_bytes = ntohl(rsp->tx_bytes); in ncsi_rsp_handler_gcps()
940 ncs->hnc_rx_uc_pkts = ntohl(rsp->rx_uc_pkts); in ncsi_rsp_handler_gcps()
941 ncs->hnc_rx_mc_pkts = ntohl(rsp->rx_mc_pkts); in ncsi_rsp_handler_gcps()
942 ncs->hnc_rx_bc_pkts = ntohl(rsp->rx_bc_pkts); in ncsi_rsp_handler_gcps()
943 ncs->hnc_tx_uc_pkts = ntohl(rsp->tx_uc_pkts); in ncsi_rsp_handler_gcps()
944 ncs->hnc_tx_mc_pkts = ntohl(rsp->tx_mc_pkts); in ncsi_rsp_handler_gcps()
945 ncs->hnc_tx_bc_pkts = ntohl(rsp->tx_bc_pkts); in ncsi_rsp_handler_gcps()
946 ncs->hnc_fcs_err = ntohl(rsp->fcs_err); in ncsi_rsp_handler_gcps()
947 ncs->hnc_align_err = ntohl(rsp->align_err); in ncsi_rsp_handler_gcps()
948 ncs->hnc_false_carrier = ntohl(rsp->false_carrier); in ncsi_rsp_handler_gcps()
949 ncs->hnc_runt_pkts = ntohl(rsp->runt_pkts); in ncsi_rsp_handler_gcps()
950 ncs->hnc_jabber_pkts = ntohl(rsp->jabber_pkts); in ncsi_rsp_handler_gcps()
951 ncs->hnc_rx_pause_xon = ntohl(rsp->rx_pause_xon); in ncsi_rsp_handler_gcps()
952 ncs->hnc_rx_pause_xoff = ntohl(rsp->rx_pause_xoff); in ncsi_rsp_handler_gcps()
953 ncs->hnc_tx_pause_xon = ntohl(rsp->tx_pause_xon); in ncsi_rsp_handler_gcps()
954 ncs->hnc_tx_pause_xoff = ntohl(rsp->tx_pause_xoff); in ncsi_rsp_handler_gcps()
955 ncs->hnc_tx_s_collision = ntohl(rsp->tx_s_collision); in ncsi_rsp_handler_gcps()
956 ncs->hnc_tx_m_collision = ntohl(rsp->tx_m_collision); in ncsi_rsp_handler_gcps()
957 ncs->hnc_l_collision = ntohl(rsp->l_collision); in ncsi_rsp_handler_gcps()
958 ncs->hnc_e_collision = ntohl(rsp->e_collision); in ncsi_rsp_handler_gcps()
959 ncs->hnc_rx_ctl_frames = ntohl(rsp->rx_ctl_frames); in ncsi_rsp_handler_gcps()
960 ncs->hnc_rx_64_frames = ntohl(rsp->rx_64_frames); in ncsi_rsp_handler_gcps()
961 ncs->hnc_rx_127_frames = ntohl(rsp->rx_127_frames); in ncsi_rsp_handler_gcps()
962 ncs->hnc_rx_255_frames = ntohl(rsp->rx_255_frames); in ncsi_rsp_handler_gcps()
963 ncs->hnc_rx_511_frames = ntohl(rsp->rx_511_frames); in ncsi_rsp_handler_gcps()
964 ncs->hnc_rx_1023_frames = ntohl(rsp->rx_1023_frames); in ncsi_rsp_handler_gcps()
965 ncs->hnc_rx_1522_frames = ntohl(rsp->rx_1522_frames); in ncsi_rsp_handler_gcps()
966 ncs->hnc_rx_9022_frames = ntohl(rsp->rx_9022_frames); in ncsi_rsp_handler_gcps()
967 ncs->hnc_tx_64_frames = ntohl(rsp->tx_64_frames); in ncsi_rsp_handler_gcps()
968 ncs->hnc_tx_127_frames = ntohl(rsp->tx_127_frames); in ncsi_rsp_handler_gcps()
969 ncs->hnc_tx_255_frames = ntohl(rsp->tx_255_frames); in ncsi_rsp_handler_gcps()
970 ncs->hnc_tx_511_frames = ntohl(rsp->tx_511_frames); in ncsi_rsp_handler_gcps()
971 ncs->hnc_tx_1023_frames = ntohl(rsp->tx_1023_frames); in ncsi_rsp_handler_gcps()
972 ncs->hnc_tx_1522_frames = ntohl(rsp->tx_1522_frames); in ncsi_rsp_handler_gcps()
973 ncs->hnc_tx_9022_frames = ntohl(rsp->tx_9022_frames); in ncsi_rsp_handler_gcps()
974 ncs->hnc_rx_valid_bytes = ntohl(rsp->rx_valid_bytes); in ncsi_rsp_handler_gcps()
975 ncs->hnc_rx_runt_pkts = ntohl(rsp->rx_runt_pkts); in ncsi_rsp_handler_gcps()
976 ncs->hnc_rx_jabber_pkts = ntohl(rsp->rx_jabber_pkts); in ncsi_rsp_handler_gcps()
984 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_gns()
988 /* Find the channel */ in ncsi_rsp_handler_gns()
989 rsp = (struct ncsi_rsp_gns_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_gns()
990 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_gns()
993 return -ENODEV; in ncsi_rsp_handler_gns()
996 ncs = &nc->stats; in ncsi_rsp_handler_gns()
997 ncs->ncsi_rx_cmds = ntohl(rsp->rx_cmds); in ncsi_rsp_handler_gns()
998 ncs->ncsi_dropped_cmds = ntohl(rsp->dropped_cmds); in ncsi_rsp_handler_gns()
999 ncs->ncsi_cmd_type_errs = ntohl(rsp->cmd_type_errs); in ncsi_rsp_handler_gns()
1000 ncs->ncsi_cmd_csum_errs = ntohl(rsp->cmd_csum_errs); in ncsi_rsp_handler_gns()
1001 ncs->ncsi_rx_pkts = ntohl(rsp->rx_pkts); in ncsi_rsp_handler_gns()
1002 ncs->ncsi_tx_pkts = ntohl(rsp->tx_pkts); in ncsi_rsp_handler_gns()
1003 ncs->ncsi_tx_aen_pkts = ntohl(rsp->tx_aen_pkts); in ncsi_rsp_handler_gns()
1011 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_gnpts()
1015 /* Find the channel */ in ncsi_rsp_handler_gnpts()
1016 rsp = (struct ncsi_rsp_gnpts_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_gnpts()
1017 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_gnpts()
1020 return -ENODEV; in ncsi_rsp_handler_gnpts()
1023 ncs = &nc->stats; in ncsi_rsp_handler_gnpts()
1024 ncs->pt_tx_pkts = ntohl(rsp->tx_pkts); in ncsi_rsp_handler_gnpts()
1025 ncs->pt_tx_dropped = ntohl(rsp->tx_dropped); in ncsi_rsp_handler_gnpts()
1026 ncs->pt_tx_channel_err = ntohl(rsp->tx_channel_err); in ncsi_rsp_handler_gnpts()
1027 ncs->pt_tx_us_err = ntohl(rsp->tx_us_err); in ncsi_rsp_handler_gnpts()
1028 ncs->pt_rx_pkts = ntohl(rsp->rx_pkts); in ncsi_rsp_handler_gnpts()
1029 ncs->pt_rx_dropped = ntohl(rsp->rx_dropped); in ncsi_rsp_handler_gnpts()
1030 ncs->pt_rx_channel_err = ntohl(rsp->rx_channel_err); in ncsi_rsp_handler_gnpts()
1031 ncs->pt_rx_us_err = ntohl(rsp->rx_us_err); in ncsi_rsp_handler_gnpts()
1032 ncs->pt_rx_os_err = ntohl(rsp->rx_os_err); in ncsi_rsp_handler_gnpts()
1040 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_gps()
1044 rsp = (struct ncsi_rsp_gps_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_gps()
1045 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_gps()
1048 return -ENODEV; in ncsi_rsp_handler_gps()
1056 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_gpuuid()
1060 rsp = (struct ncsi_rsp_gpuuid_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_gpuuid()
1061 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_gpuuid()
1064 return -ENODEV; in ncsi_rsp_handler_gpuuid()
1066 memcpy(np->uuid, rsp->uuid, sizeof(rsp->uuid)); in ncsi_rsp_handler_gpuuid()
1078 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_netlink()
1085 rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_netlink()
1086 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, in ncsi_rsp_handler_netlink()
1089 return -ENODEV; in ncsi_rsp_handler_netlink()
1098 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_rsp_handler_gmcma()
1099 struct net_device *ndev = ndp->ndev.dev; in ncsi_rsp_handler_gmcma()
1102 int ret = -1; in ncsi_rsp_handler_gmcma()
1105 rsp = (struct ncsi_rsp_gmcma_pkt *)skb_network_header(nr->rsp); in ncsi_rsp_handler_gmcma()
1106 saddr.sa_family = ndev->type; in ncsi_rsp_handler_gmcma()
1107 ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE; in ncsi_rsp_handler_gmcma()
1110 rsp->address_count); in ncsi_rsp_handler_gmcma()
1111 for (i = 0; i < rsp->address_count; i++) { in ncsi_rsp_handler_gmcma()
1113 i, rsp->addresses[i][0], rsp->addresses[i][1], in ncsi_rsp_handler_gmcma()
1114 rsp->addresses[i][2], rsp->addresses[i][3], in ncsi_rsp_handler_gmcma()
1115 rsp->addresses[i][4], rsp->addresses[i][5]); in ncsi_rsp_handler_gmcma()
1118 for (i = 0; i < rsp->address_count; i++) { in ncsi_rsp_handler_gmcma()
1119 memcpy(saddr.sa_data, &rsp->addresses[i], ETH_ALEN); in ncsi_rsp_handler_gmcma()
1120 ret = ndev->netdev_ops->ndo_set_mac_address(ndev, &saddr); in ncsi_rsp_handler_gmcma()
1130 ndp->gma_flag = ret == 0; in ncsi_rsp_handler_gmcma()
1161 { NCSI_PKT_RSP_GP, -1, ncsi_rsp_handler_gp },
1166 { NCSI_PKT_RSP_OEM, -1, ncsi_rsp_handler_oem },
1167 { NCSI_PKT_RSP_PLDM, -1, ncsi_rsp_handler_pldm },
1169 { NCSI_PKT_RSP_QPNPR, -1, ncsi_rsp_handler_pldm },
1170 { NCSI_PKT_RSP_SNPR, -1, ncsi_rsp_handler_pldm },
1171 { NCSI_PKT_RSP_GMCMA, -1, ncsi_rsp_handler_gmcma },
1189 return -ENODEV; in ncsi_rcv_rsp()
1193 if (hdr->type == NCSI_PKT_AEN) in ncsi_rcv_rsp()
1198 if (ncsi_rsp_handlers[i].type == hdr->type) { in ncsi_rcv_rsp()
1209 netdev_err(nd->dev, "Received unrecognized packet (0x%x)\n", in ncsi_rcv_rsp()
1210 hdr->type); in ncsi_rcv_rsp()
1211 return -ENOENT; in ncsi_rcv_rsp()
1215 spin_lock_irqsave(&ndp->lock, flags); in ncsi_rcv_rsp()
1216 nr = &ndp->requests[hdr->id]; in ncsi_rcv_rsp()
1217 if (!nr->used) { in ncsi_rcv_rsp()
1218 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_rcv_rsp()
1219 return -ENODEV; in ncsi_rcv_rsp()
1222 nr->rsp = skb; in ncsi_rcv_rsp()
1223 if (!nr->enabled) { in ncsi_rcv_rsp()
1224 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_rcv_rsp()
1225 ret = -ENOENT; in ncsi_rcv_rsp()
1230 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_rcv_rsp()
1231 payload = nrh->payload; in ncsi_rcv_rsp()
1233 payload = ntohs(hdr->length); in ncsi_rcv_rsp()
1236 netdev_warn(ndp->ndev.dev, in ncsi_rcv_rsp()
1238 hdr->type); in ncsi_rcv_rsp()
1240 if (nr->flags == NCSI_REQ_FLAG_NETLINK_DRIVEN) { in ncsi_rcv_rsp()
1241 if (ret == -EPERM) in ncsi_rcv_rsp()
1244 ncsi_send_netlink_err(ndp->ndev.dev, in ncsi_rcv_rsp()
1245 nr->snd_seq, in ncsi_rcv_rsp()
1246 nr->snd_portid, in ncsi_rcv_rsp()
1247 &nr->nlhdr, in ncsi_rcv_rsp()
1254 ret = nrh->handler(nr); in ncsi_rcv_rsp()
1256 netdev_err(ndp->ndev.dev, in ncsi_rcv_rsp()
1258 hdr->type, ret); in ncsi_rcv_rsp()
1261 if (nr->flags == NCSI_REQ_FLAG_NETLINK_DRIVEN) { in ncsi_rcv_rsp()
1264 netdev_err(ndp->ndev.dev, in ncsi_rcv_rsp()
1266 hdr->type, ret); in ncsi_rcv_rsp()