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