Lines Matching full:nic
24 static int aq_clear_txsc(struct aq_nic_s *nic, const int txsc_idx,
26 static int aq_clear_txsa(struct aq_nic_s *nic, struct aq_macsec_txsc *aq_txsc,
28 static int aq_clear_rxsc(struct aq_nic_s *nic, const int rxsc_idx,
30 static int aq_clear_rxsa(struct aq_nic_s *nic, struct aq_macsec_rxsc *aq_rxsc,
32 static int aq_clear_secy(struct aq_nic_s *nic, const struct macsec_secy *secy,
34 static int aq_apply_macsec_cfg(struct aq_nic_s *nic);
35 static int aq_apply_secy_cfg(struct aq_nic_s *nic,
292 struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev); in aq_mdo_dev_open() local
295 if (netif_carrier_ok(nic->ndev)) in aq_mdo_dev_open()
296 ret = aq_apply_secy_cfg(nic, ctx->secy); in aq_mdo_dev_open()
303 struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev); in aq_mdo_dev_stop() local
307 if (nic->macsec_cfg->txsc_idx_busy & BIT(i)) in aq_mdo_dev_stop()
308 aq_clear_secy(nic, nic->macsec_cfg->aq_txsc[i].sw_secy, in aq_mdo_dev_stop()
315 static int aq_set_txsc(struct aq_nic_s *nic, const int txsc_idx) in aq_set_txsc() argument
317 struct aq_macsec_txsc *aq_txsc = &nic->macsec_cfg->aq_txsc[txsc_idx]; in aq_set_txsc()
322 struct aq_hw_s *hw = nic->aq_hw; in aq_set_txsc()
337 tx_class_rec.sc_sa = nic->macsec_cfg->sc_sa; in aq_set_txsc()
442 struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev); in aq_mdo_add_secy() local
443 struct aq_macsec_cfg *cfg = nic->macsec_cfg; in aq_mdo_add_secy()
467 if (netif_carrier_ok(nic->ndev) && netif_running(secy->netdev)) in aq_mdo_add_secy()
468 ret = aq_set_txsc(nic, txsc_idx); in aq_mdo_add_secy()
477 struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev); in aq_mdo_upd_secy() local
482 txsc_idx = aq_get_txsc_idx_from_secy(nic->macsec_cfg, secy); in aq_mdo_upd_secy()
486 if (netif_carrier_ok(nic->ndev) && netif_running(secy->netdev)) in aq_mdo_upd_secy()
487 ret = aq_set_txsc(nic, txsc_idx); in aq_mdo_upd_secy()
492 static int aq_clear_txsc(struct aq_nic_s *nic, const int txsc_idx, in aq_clear_txsc() argument
495 struct aq_macsec_txsc *tx_sc = &nic->macsec_cfg->aq_txsc[txsc_idx]; in aq_clear_txsc()
498 struct aq_hw_s *hw = nic->aq_hw; in aq_clear_txsc()
503 ret = aq_clear_txsa(nic, tx_sc, sa_num, clear_type); in aq_clear_txsc()
522 clear_bit(txsc_idx, &nic->macsec_cfg->txsc_idx_busy); in aq_clear_txsc()
523 nic->macsec_cfg->aq_txsc[txsc_idx].sw_secy = NULL; in aq_clear_txsc()
531 struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev); in aq_mdo_del_secy() local
534 if (!nic->macsec_cfg) in aq_mdo_del_secy()
537 ret = aq_clear_secy(nic, ctx->secy, AQ_CLEAR_ALL); in aq_mdo_del_secy()
542 static int aq_update_txsa(struct aq_nic_s *nic, const unsigned int sc_idx, in aq_update_txsa() argument
551 struct aq_hw_s *hw = nic->aq_hw; in aq_update_txsa()
579 struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev); in aq_mdo_add_txsa() local
580 struct aq_macsec_cfg *cfg = nic->macsec_cfg; in aq_mdo_add_txsa()
596 if (netif_carrier_ok(nic->ndev) && netif_running(secy->netdev)) in aq_mdo_add_txsa()
597 ret = aq_update_txsa(nic, aq_txsc->hw_sc_idx, secy, in aq_mdo_add_txsa()
606 struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev); in aq_mdo_upd_txsa() local
607 struct aq_macsec_cfg *cfg = nic->macsec_cfg; in aq_mdo_upd_txsa()
618 if (netif_carrier_ok(nic->ndev) && netif_running(secy->netdev)) in aq_mdo_upd_txsa()
619 ret = aq_update_txsa(nic, aq_txsc->hw_sc_idx, secy, in aq_mdo_upd_txsa()
625 static int aq_clear_txsa(struct aq_nic_s *nic, struct aq_macsec_txsc *aq_txsc, in aq_clear_txsa() argument
629 struct aq_hw_s *hw = nic->aq_hw; in aq_clear_txsa()
635 if ((clear_type & AQ_CLEAR_HW) && netif_carrier_ok(nic->ndev)) { in aq_clear_txsa()
655 struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev); in aq_mdo_del_txsa() local
656 struct aq_macsec_cfg *cfg = nic->macsec_cfg; in aq_mdo_del_txsa()
664 ret = aq_clear_txsa(nic, &cfg->aq_txsc[txsc_idx], ctx->sa.assoc_num, in aq_mdo_del_txsa()
686 static int aq_set_rxsc(struct aq_nic_s *nic, const u32 rxsc_idx) in aq_set_rxsc() argument
689 &nic->macsec_cfg->aq_rxsc[rxsc_idx]; in aq_set_rxsc()
695 struct aq_hw_s *hw = nic->aq_hw; in aq_set_rxsc()
708 pre_class_record.an_mask = nic->macsec_cfg->sc_sa; in aq_set_rxsc()
747 struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev); in aq_mdo_add_rxsc() local
748 struct aq_macsec_cfg *cfg = nic->macsec_cfg; in aq_mdo_add_rxsc()
765 if (netif_carrier_ok(nic->ndev) && netif_running(ctx->secy->netdev)) in aq_mdo_add_rxsc()
766 ret = aq_set_rxsc(nic, rxsc_idx); in aq_mdo_add_rxsc()
778 struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev); in aq_mdo_upd_rxsc() local
782 rxsc_idx = aq_get_rxsc_idx_from_rxsc(nic->macsec_cfg, ctx->rx_sc); in aq_mdo_upd_rxsc()
786 if (netif_carrier_ok(nic->ndev) && netif_running(ctx->secy->netdev)) in aq_mdo_upd_rxsc()
787 ret = aq_set_rxsc(nic, rxsc_idx); in aq_mdo_upd_rxsc()
792 static int aq_clear_rxsc(struct aq_nic_s *nic, const int rxsc_idx, in aq_clear_rxsc() argument
795 struct aq_macsec_rxsc *rx_sc = &nic->macsec_cfg->aq_rxsc[rxsc_idx]; in aq_clear_rxsc()
796 struct aq_hw_s *hw = nic->aq_hw; in aq_clear_rxsc()
801 ret = aq_clear_rxsa(nic, rx_sc, sa_num, clear_type); in aq_clear_rxsc()
831 clear_bit(rxsc_idx, &nic->macsec_cfg->rxsc_idx_busy); in aq_clear_rxsc()
841 struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev); in aq_mdo_del_rxsc() local
846 rxsc_idx = aq_get_rxsc_idx_from_rxsc(nic->macsec_cfg, ctx->rx_sc); in aq_mdo_del_rxsc()
850 if (netif_carrier_ok(nic->ndev)) in aq_mdo_del_rxsc()
853 ret = aq_clear_rxsc(nic, rxsc_idx, clear_type); in aq_mdo_del_rxsc()
858 static int aq_update_rxsa(struct aq_nic_s *nic, const unsigned int sc_idx, in aq_update_rxsa() argument
866 struct aq_hw_s *hw = nic->aq_hw; in aq_update_rxsa()
909 struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev); in aq_mdo_add_rxsa() local
916 rxsc_idx = aq_get_rxsc_idx_from_rxsc(nic->macsec_cfg, rx_sc); in aq_mdo_add_rxsa()
920 aq_rxsc = &nic->macsec_cfg->aq_rxsc[rxsc_idx]; in aq_mdo_add_rxsa()
926 if (netif_carrier_ok(nic->ndev) && netif_running(secy->netdev)) in aq_mdo_add_rxsa()
927 ret = aq_update_rxsa(nic, aq_rxsc->hw_sc_idx, secy, in aq_mdo_add_rxsa()
936 struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev); in aq_mdo_upd_rxsa() local
938 struct aq_macsec_cfg *cfg = nic->macsec_cfg; in aq_mdo_upd_rxsa()
947 if (netif_carrier_ok(nic->ndev) && netif_running(secy->netdev)) in aq_mdo_upd_rxsa()
948 ret = aq_update_rxsa(nic, cfg->aq_rxsc[rxsc_idx].hw_sc_idx, in aq_mdo_upd_rxsa()
955 static int aq_clear_rxsa(struct aq_nic_s *nic, struct aq_macsec_rxsc *aq_rxsc, in aq_clear_rxsa() argument
959 struct aq_hw_s *hw = nic->aq_hw; in aq_clear_rxsa()
965 if ((clear_type & AQ_CLEAR_HW) && netif_carrier_ok(nic->ndev)) { in aq_clear_rxsa()
985 struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev); in aq_mdo_del_rxsa() local
987 struct aq_macsec_cfg *cfg = nic->macsec_cfg; in aq_mdo_del_rxsa()
995 ret = aq_clear_rxsa(nic, &cfg->aq_rxsc[rxsc_idx], ctx->sa.assoc_num, in aq_mdo_del_rxsa()
1003 struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev); in aq_mdo_get_dev_stats() local
1004 struct aq_macsec_common_stats *stats = &nic->macsec_cfg->stats; in aq_mdo_get_dev_stats()
1005 struct aq_hw_s *hw = nic->aq_hw; in aq_mdo_get_dev_stats()
1023 struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev); in aq_mdo_get_tx_sc_stats() local
1025 struct aq_hw_s *hw = nic->aq_hw; in aq_mdo_get_tx_sc_stats()
1029 txsc_idx = aq_get_txsc_idx_from_secy(nic->macsec_cfg, ctx->secy); in aq_mdo_get_tx_sc_stats()
1033 aq_txsc = &nic->macsec_cfg->aq_txsc[txsc_idx]; in aq_mdo_get_tx_sc_stats()
1047 struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev); in aq_mdo_get_tx_sa_stats() local
1048 struct aq_macsec_cfg *cfg = nic->macsec_cfg; in aq_mdo_get_tx_sa_stats()
1050 struct aq_hw_s *hw = nic->aq_hw; in aq_mdo_get_tx_sa_stats()
1087 struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev); in aq_mdo_get_rx_sc_stats() local
1088 struct aq_macsec_cfg *cfg = nic->macsec_cfg; in aq_mdo_get_rx_sc_stats()
1090 struct aq_hw_s *hw = nic->aq_hw; in aq_mdo_get_rx_sc_stats()
1132 struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev); in aq_mdo_get_rx_sa_stats() local
1133 struct aq_macsec_cfg *cfg = nic->macsec_cfg; in aq_mdo_get_rx_sa_stats()
1135 struct aq_hw_s *hw = nic->aq_hw; in aq_mdo_get_rx_sa_stats()
1171 static int apply_txsc_cfg(struct aq_nic_s *nic, const int txsc_idx) in apply_txsc_cfg() argument
1173 struct aq_macsec_txsc *aq_txsc = &nic->macsec_cfg->aq_txsc[txsc_idx]; in apply_txsc_cfg()
1182 ret = aq_set_txsc(nic, txsc_idx); in apply_txsc_cfg()
1189 ret = aq_update_txsa(nic, aq_txsc->hw_sc_idx, secy, in apply_txsc_cfg()
1199 static int apply_rxsc_cfg(struct aq_nic_s *nic, const int rxsc_idx) in apply_rxsc_cfg() argument
1201 struct aq_macsec_rxsc *aq_rxsc = &nic->macsec_cfg->aq_rxsc[rxsc_idx]; in apply_rxsc_cfg()
1210 ret = aq_set_rxsc(nic, rxsc_idx); in apply_rxsc_cfg()
1217 ret = aq_update_rxsa(nic, aq_rxsc->hw_sc_idx, secy, in apply_rxsc_cfg()
1227 static int aq_clear_secy(struct aq_nic_s *nic, const struct macsec_secy *secy, in aq_clear_secy() argument
1235 txsc_idx = aq_get_txsc_idx_from_secy(nic->macsec_cfg, secy); in aq_clear_secy()
1237 ret = aq_clear_txsc(nic, txsc_idx, clear_type); in aq_clear_secy()
1244 rxsc_idx = aq_get_rxsc_idx_from_rxsc(nic->macsec_cfg, rx_sc); in aq_clear_secy()
1248 ret = aq_clear_rxsc(nic, rxsc_idx, clear_type); in aq_clear_secy()
1256 static int aq_apply_secy_cfg(struct aq_nic_s *nic, in aq_apply_secy_cfg() argument
1264 txsc_idx = aq_get_txsc_idx_from_secy(nic->macsec_cfg, secy); in aq_apply_secy_cfg()
1266 apply_txsc_cfg(nic, txsc_idx); in aq_apply_secy_cfg()
1270 rxsc_idx = aq_get_rxsc_idx_from_rxsc(nic->macsec_cfg, rx_sc); in aq_apply_secy_cfg()
1274 ret = apply_rxsc_cfg(nic, rxsc_idx); in aq_apply_secy_cfg()
1282 static int aq_apply_macsec_cfg(struct aq_nic_s *nic) in aq_apply_macsec_cfg() argument
1288 if (nic->macsec_cfg->txsc_idx_busy & BIT(i)) { in aq_apply_macsec_cfg()
1289 ret = apply_txsc_cfg(nic, i); in aq_apply_macsec_cfg()
1296 if (nic->macsec_cfg->rxsc_idx_busy & BIT(i)) { in aq_apply_macsec_cfg()
1297 ret = apply_rxsc_cfg(nic, i); in aq_apply_macsec_cfg()
1337 static void aq_check_txsa_expiration(struct aq_nic_s *nic) in aq_check_txsa_expiration() argument
1340 struct aq_macsec_cfg *cfg = nic->macsec_cfg; in aq_check_txsa_expiration()
1341 struct aq_hw_s *hw = nic->aq_hw; in aq_check_txsa_expiration()
1370 netdev_warn(nic->ndev, in aq_check_txsa_expiration()
1377 netdev_warn(nic->ndev, in aq_check_txsa_expiration()
1383 netdev_warn(nic->ndev, in aq_check_txsa_expiration()
1402 struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev); \
1404 mutex_lock(&nic->macsec_mutex); \
1406 mutex_unlock(&nic->macsec_mutex); \
1452 int aq_macsec_init(struct aq_nic_s *nic) in aq_macsec_init() argument
1457 if (!nic->aq_fw_ops->get_link_capabilities) in aq_macsec_init()
1460 caps_lo = nic->aq_fw_ops->get_link_capabilities(nic->aq_hw); in aq_macsec_init()
1465 nic->macsec_cfg = kzalloc(sizeof(*cfg), GFP_KERNEL); in aq_macsec_init()
1466 if (!nic->macsec_cfg) in aq_macsec_init()
1469 nic->ndev->features |= NETIF_F_HW_MACSEC; in aq_macsec_init()
1470 nic->ndev->macsec_ops = &aq_macsec_ops; in aq_macsec_init()
1471 mutex_init(&nic->macsec_mutex); in aq_macsec_init()
1476 void aq_macsec_free(struct aq_nic_s *nic) in aq_macsec_free() argument
1478 kfree(nic->macsec_cfg); in aq_macsec_free()
1479 nic->macsec_cfg = NULL; in aq_macsec_free()
1482 int aq_macsec_enable(struct aq_nic_s *nic) in aq_macsec_enable() argument
1487 struct aq_hw_s *hw = nic->aq_hw; in aq_macsec_enable()
1492 if (!nic->macsec_cfg) in aq_macsec_enable()
1495 mutex_lock(&nic->macsec_mutex); in aq_macsec_enable()
1497 if (nic->aq_fw_ops->send_macsec_req) { in aq_macsec_enable()
1508 ret = nic->aq_fw_ops->send_macsec_req(hw, &msg, &resp); in aq_macsec_enable()
1541 ret = aq_apply_macsec_cfg(nic); in aq_macsec_enable()
1544 mutex_unlock(&nic->macsec_mutex); in aq_macsec_enable()
1548 void aq_macsec_work(struct aq_nic_s *nic) in aq_macsec_work() argument
1550 if (!nic->macsec_cfg) in aq_macsec_work()
1553 if (!netif_carrier_ok(nic->ndev)) in aq_macsec_work()
1556 mutex_lock(&nic->macsec_mutex); in aq_macsec_work()
1557 aq_check_txsa_expiration(nic); in aq_macsec_work()
1558 mutex_unlock(&nic->macsec_mutex); in aq_macsec_work()
1561 int aq_macsec_rx_sa_cnt(struct aq_nic_s *nic) in aq_macsec_rx_sa_cnt() argument
1563 struct aq_macsec_cfg *cfg = nic->macsec_cfg; in aq_macsec_rx_sa_cnt()
1569 mutex_lock(&nic->macsec_mutex); in aq_macsec_rx_sa_cnt()
1577 mutex_unlock(&nic->macsec_mutex); in aq_macsec_rx_sa_cnt()
1581 int aq_macsec_tx_sc_cnt(struct aq_nic_s *nic) in aq_macsec_tx_sc_cnt() argument
1585 if (!nic->macsec_cfg) in aq_macsec_tx_sc_cnt()
1588 mutex_lock(&nic->macsec_mutex); in aq_macsec_tx_sc_cnt()
1589 cnt = hweight_long(nic->macsec_cfg->txsc_idx_busy); in aq_macsec_tx_sc_cnt()
1590 mutex_unlock(&nic->macsec_mutex); in aq_macsec_tx_sc_cnt()
1595 int aq_macsec_tx_sa_cnt(struct aq_nic_s *nic) in aq_macsec_tx_sa_cnt() argument
1597 struct aq_macsec_cfg *cfg = nic->macsec_cfg; in aq_macsec_tx_sa_cnt()
1603 mutex_lock(&nic->macsec_mutex); in aq_macsec_tx_sa_cnt()
1611 mutex_unlock(&nic->macsec_mutex); in aq_macsec_tx_sa_cnt()
1615 static int aq_macsec_update_stats(struct aq_nic_s *nic) in aq_macsec_update_stats() argument
1617 struct aq_macsec_cfg *cfg = nic->macsec_cfg; in aq_macsec_update_stats()
1618 struct aq_hw_s *hw = nic->aq_hw; in aq_macsec_update_stats()
1667 u64 *aq_macsec_get_stats(struct aq_nic_s *nic, u64 *data) in aq_macsec_get_stats() argument
1669 struct aq_macsec_cfg *cfg = nic->macsec_cfg; in aq_macsec_get_stats()
1683 mutex_lock(&nic->macsec_mutex); in aq_macsec_get_stats()
1685 aq_macsec_update_stats(nic); in aq_macsec_get_stats()
1767 mutex_unlock(&nic->macsec_mutex); in aq_macsec_get_stats()