Lines Matching refs:ndev
103 int hns_nic_net_xmit_hw(struct net_device *ndev, in hns_nic_net_xmit_hw() argument
107 struct hns_nic_priv *priv = netdev_priv(ndev); in hns_nic_net_xmit_hw()
132 netdev_err(ndev, "no memory to xmit!\n"); in hns_nic_net_xmit_hw()
150 netdev_err(ndev, "TX head DMA map failed\n"); in hns_nic_net_xmit_hw()
163 netdev_err(ndev, "TX frag(%d) DMA map failed\n", i); in hns_nic_net_xmit_hw()
172 dev_queue = netdev_get_tx_queue(ndev, skb->queue_mapping); in hns_nic_net_xmit_hw()
205 netif_stop_subqueue(ndev, skb->queue_mapping); in hns_nic_net_xmit_hw()
336 struct net_device *ndev = ring_data->napi.dev; in hns_nic_poll_rx_skb() local
356 netdev_err(ndev, "alloc rx skb fail\n"); in hns_nic_poll_rx_skb()
414 netdev_err(ndev, "invalid bnum(%d,%d,%d,%d),%016llx,%016llx\n", in hns_nic_poll_rx_skb()
426 netdev_err(ndev, "no valid bd,%016llx,%016llx\n", in hns_nic_poll_rx_skb()
467 struct net_device *ndev = ring_data->napi.dev; in hns_nic_alloc_rx_buffers() local
478 netdev_err(ndev, "hnae reserve buffer map failed.\n"); in hns_nic_alloc_rx_buffers()
496 struct net_device *ndev = ring_data->napi.dev; in hns_nic_rx_up_pro() local
498 skb->protocol = eth_type_trans(skb, ndev); in hns_nic_rx_up_pro()
500 ndev->last_rx = jiffies; in hns_nic_rx_up_pro()
606 #define NETIF_TX_LOCK(ndev) netif_tx_lock(ndev) argument
607 #define NETIF_TX_UNLOCK(ndev) netif_tx_unlock(ndev) argument
609 #define NETIF_TX_LOCK(ndev) argument
610 #define NETIF_TX_UNLOCK(ndev) argument
619 struct net_device *ndev = ring_data->napi.dev; in hns_nic_tx_poll_one() local
621 struct hns_nic_priv *priv = netdev_priv(ndev); in hns_nic_tx_poll_one()
625 NETIF_TX_LOCK(ndev); in hns_nic_tx_poll_one()
631 NETIF_TX_UNLOCK(ndev); in hns_nic_tx_poll_one()
636 netdev_err(ndev, "wrong head (%d, %d-%d)\n", head, in hns_nic_tx_poll_one()
639 NETIF_TX_UNLOCK(ndev); in hns_nic_tx_poll_one()
648 NETIF_TX_UNLOCK(ndev); in hns_nic_tx_poll_one()
650 dev_queue = netdev_get_tx_queue(ndev, ring_data->queue_index); in hns_nic_tx_poll_one()
653 if (unlikely(pkts && netif_carrier_ok(ndev) && in hns_nic_tx_poll_one()
687 struct net_device *ndev = ring_data->napi.dev; in hns_nic_tx_clr_all_bufs() local
692 NETIF_TX_LOCK(ndev); in hns_nic_tx_clr_all_bufs()
700 NETIF_TX_UNLOCK(ndev); in hns_nic_tx_clr_all_bufs()
702 dev_queue = netdev_get_tx_queue(ndev, ring_data->queue_index); in hns_nic_tx_clr_all_bufs()
739 static void hns_nic_adjust_link(struct net_device *ndev) in hns_nic_adjust_link() argument
741 struct hns_nic_priv *priv = netdev_priv(ndev); in hns_nic_adjust_link()
744 h->dev->ops->adjust_link(h, ndev->phydev->speed, ndev->phydev->duplex); in hns_nic_adjust_link()
753 int hns_nic_init_phy(struct net_device *ndev, struct hnae_handle *h) in hns_nic_init_phy() argument
755 struct hns_nic_priv *priv = netdev_priv(ndev); in hns_nic_init_phy()
762 phy_dev = of_phy_connect(ndev, h->phy_node, in hns_nic_init_phy()
765 phy_dev = of_phy_attach(ndev, h->phy_node, 0, h->phy_if); in hns_nic_init_phy()
794 static int hns_nic_net_set_mac_address(struct net_device *ndev, void *p) in hns_nic_net_set_mac_address() argument
796 struct hns_nic_priv *priv = netdev_priv(ndev); in hns_nic_net_set_mac_address()
806 netdev_err(ndev, "set_mac_address fail, ret=%d!\n", ret); in hns_nic_net_set_mac_address()
810 memcpy(ndev->dev_addr, mac_addr->sa_data, ndev->addr_len); in hns_nic_net_set_mac_address()
824 static void hns_init_mac_addr(struct net_device *ndev) in hns_init_mac_addr() argument
826 struct hns_nic_priv *priv = netdev_priv(ndev); in hns_init_mac_addr()
832 memcpy(ndev->dev_addr, mac_addr_temp, ndev->addr_len); in hns_init_mac_addr()
834 eth_hw_addr_random(ndev); in hns_init_mac_addr()
836 ndev->dev_addr); in hns_init_mac_addr()
894 static int hns_nic_net_up(struct net_device *ndev) in hns_nic_net_up() argument
896 struct hns_nic_priv *priv = netdev_priv(ndev); in hns_nic_net_up()
903 netdev_err(ndev, "hns init irq failed! ret=%d\n", ret); in hns_nic_net_up()
908 ret = hns_nic_ring_open(ndev, i); in hns_nic_net_up()
916 ret = h->dev->ops->set_mac_addr(h, ndev->dev_addr); in hns_nic_net_up()
933 netif_stop_queue(ndev); in hns_nic_net_up()
939 hns_nic_ring_close(ndev, j); in hns_nic_net_up()
946 static void hns_nic_net_down(struct net_device *ndev) in hns_nic_net_down() argument
950 struct hns_nic_priv *priv = netdev_priv(ndev); in hns_nic_net_down()
956 netif_tx_stop_all_queues(ndev); in hns_nic_net_down()
957 netif_carrier_off(ndev); in hns_nic_net_down()
958 netif_tx_disable(ndev); in hns_nic_net_down()
969 netif_tx_stop_all_queues(ndev); in hns_nic_net_down()
972 hns_nic_ring_close(ndev, i); in hns_nic_net_down()
973 hns_nic_ring_close(ndev, i + priv->ae_handle->q_num); in hns_nic_net_down()
980 void hns_nic_net_reset(struct net_device *ndev) in hns_nic_net_reset() argument
982 struct hns_nic_priv *priv = netdev_priv(ndev); in hns_nic_net_reset()
1007 static int hns_nic_net_open(struct net_device *ndev) in hns_nic_net_open() argument
1009 struct hns_nic_priv *priv = netdev_priv(ndev); in hns_nic_net_open()
1017 netif_carrier_off(ndev); in hns_nic_net_open()
1019 ret = netif_set_real_num_tx_queues(ndev, h->q_num); in hns_nic_net_open()
1021 netdev_err(ndev, "netif_set_real_num_tx_queues fail, ret=%d!\n", in hns_nic_net_open()
1026 ret = netif_set_real_num_rx_queues(ndev, h->q_num); in hns_nic_net_open()
1028 netdev_err(ndev, in hns_nic_net_open()
1033 ret = hns_nic_net_up(ndev); in hns_nic_net_open()
1035 netdev_err(ndev, in hns_nic_net_open()
1043 static int hns_nic_net_stop(struct net_device *ndev) in hns_nic_net_stop() argument
1045 hns_nic_net_down(ndev); in hns_nic_net_stop()
1051 static void hns_nic_net_timeout(struct net_device *ndev) in hns_nic_net_timeout() argument
1053 struct hns_nic_priv *priv = netdev_priv(ndev); in hns_nic_net_timeout()
1075 void hns_nic_poll_controller(struct net_device *ndev) in hns_nic_poll_controller() argument
1077 struct hns_nic_priv *priv = netdev_priv(ndev); in hns_nic_poll_controller()
1089 struct net_device *ndev) in hns_nic_net_xmit() argument
1091 struct hns_nic_priv *priv = netdev_priv(ndev); in hns_nic_net_xmit()
1094 assert(skb->queue_mapping < ndev->ae_handle->q_num); in hns_nic_net_xmit()
1095 ret = hns_nic_net_xmit_hw(ndev, skb, in hns_nic_net_xmit()
1098 ndev->trans_start = jiffies; in hns_nic_net_xmit()
1099 ndev->stats.tx_bytes += skb->len; in hns_nic_net_xmit()
1100 ndev->stats.tx_packets++; in hns_nic_net_xmit()
1105 static int hns_nic_change_mtu(struct net_device *ndev, int new_mtu) in hns_nic_change_mtu() argument
1107 struct hns_nic_priv *priv = netdev_priv(ndev); in hns_nic_change_mtu()
1118 if (netif_running(ndev)) { in hns_nic_change_mtu()
1119 (void)hns_nic_net_stop(ndev); in hns_nic_change_mtu()
1124 netdev_err(ndev, "set mtu fail, return value %d\n", in hns_nic_change_mtu()
1127 if (hns_nic_net_open(ndev)) in hns_nic_change_mtu()
1128 netdev_err(ndev, "hns net open fail\n"); in hns_nic_change_mtu()
1134 ndev->mtu = new_mtu; in hns_nic_change_mtu()
1146 void hns_set_multicast_list(struct net_device *ndev) in hns_set_multicast_list() argument
1148 struct hns_nic_priv *priv = netdev_priv(ndev); in hns_set_multicast_list()
1153 netdev_err(ndev, "hnae handle is null\n"); in hns_set_multicast_list()
1158 netdev_for_each_mc_addr(ha, ndev) in hns_set_multicast_list()
1160 netdev_err(ndev, "set multicast fail\n"); in hns_set_multicast_list()
1164 void hns_nic_set_rx_mode(struct net_device *ndev) in hns_nic_set_rx_mode() argument
1166 struct hns_nic_priv *priv = netdev_priv(ndev); in hns_nic_set_rx_mode()
1170 if (ndev->flags & IFF_PROMISC) in hns_nic_set_rx_mode()
1176 hns_set_multicast_list(ndev); in hns_nic_set_rx_mode()
1179 struct rtnl_link_stats64 *hns_nic_get_stats64(struct net_device *ndev, in hns_nic_get_stats64() argument
1187 struct hns_nic_priv *priv = netdev_priv(ndev); in hns_nic_get_stats64()
1202 stats->rx_errors = ndev->stats.rx_errors; in hns_nic_get_stats64()
1203 stats->multicast = ndev->stats.multicast; in hns_nic_get_stats64()
1204 stats->rx_length_errors = ndev->stats.rx_length_errors; in hns_nic_get_stats64()
1205 stats->rx_crc_errors = ndev->stats.rx_crc_errors; in hns_nic_get_stats64()
1206 stats->rx_missed_errors = ndev->stats.rx_missed_errors; in hns_nic_get_stats64()
1208 stats->tx_errors = ndev->stats.tx_errors; in hns_nic_get_stats64()
1209 stats->rx_dropped = ndev->stats.rx_dropped; in hns_nic_get_stats64()
1210 stats->tx_dropped = ndev->stats.tx_dropped; in hns_nic_get_stats64()
1211 stats->collisions = ndev->stats.collisions; in hns_nic_get_stats64()
1212 stats->rx_over_errors = ndev->stats.rx_over_errors; in hns_nic_get_stats64()
1213 stats->rx_frame_errors = ndev->stats.rx_frame_errors; in hns_nic_get_stats64()
1214 stats->rx_fifo_errors = ndev->stats.rx_fifo_errors; in hns_nic_get_stats64()
1215 stats->tx_aborted_errors = ndev->stats.tx_aborted_errors; in hns_nic_get_stats64()
1216 stats->tx_carrier_errors = ndev->stats.tx_carrier_errors; in hns_nic_get_stats64()
1217 stats->tx_fifo_errors = ndev->stats.tx_fifo_errors; in hns_nic_get_stats64()
1218 stats->tx_heartbeat_errors = ndev->stats.tx_heartbeat_errors; in hns_nic_get_stats64()
1219 stats->tx_window_errors = ndev->stats.tx_window_errors; in hns_nic_get_stats64()
1220 stats->rx_compressed = ndev->stats.rx_compressed; in hns_nic_get_stats64()
1221 stats->tx_compressed = ndev->stats.tx_compressed; in hns_nic_get_stats64()
1449 static int hns_nic_try_get_ae(struct net_device *ndev) in hns_nic_try_get_ae() argument
1451 struct hns_nic_priv *priv = netdev_priv(ndev); in hns_nic_try_get_ae()
1464 ret = hns_nic_init_phy(ndev, h); in hns_nic_try_get_ae()
1476 ret = register_netdev(ndev); in hns_nic_try_get_ae()
1512 struct net_device *ndev; in hns_nic_dev_probe() local
1517 ndev = alloc_etherdev_mq(sizeof(struct hns_nic_priv), NIC_MAX_Q_PER_VF); in hns_nic_dev_probe()
1518 if (!ndev) in hns_nic_dev_probe()
1521 platform_set_drvdata(pdev, ndev); in hns_nic_dev_probe()
1523 priv = netdev_priv(ndev); in hns_nic_dev_probe()
1525 priv->netdev = ndev; in hns_nic_dev_probe()
1540 hns_init_mac_addr(ndev); in hns_nic_dev_probe()
1542 ndev->watchdog_timeo = HNS_NIC_TX_TIMEOUT; in hns_nic_dev_probe()
1543 ndev->priv_flags |= IFF_UNICAST_FLT; in hns_nic_dev_probe()
1544 ndev->netdev_ops = &hns_nic_netdev_ops; in hns_nic_dev_probe()
1545 hns_ethtool_set_ops(ndev); in hns_nic_dev_probe()
1546 ndev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | in hns_nic_dev_probe()
1549 ndev->vlan_features |= in hns_nic_dev_probe()
1551 ndev->vlan_features |= NETIF_F_SG | NETIF_F_GSO | NETIF_F_GRO; in hns_nic_dev_probe()
1553 SET_NETDEV_DEV(ndev, dev); in hns_nic_dev_probe()
1561 netif_carrier_off(ndev); in hns_nic_dev_probe()
1586 free_netdev(ndev); in hns_nic_dev_probe()
1592 struct net_device *ndev = platform_get_drvdata(pdev); in hns_nic_dev_remove() local
1593 struct hns_nic_priv *priv = netdev_priv(ndev); in hns_nic_dev_remove()
1595 if (ndev->reg_state != NETREG_UNINITIALIZED) in hns_nic_dev_remove()
1596 unregister_netdev(ndev); in hns_nic_dev_remove()
1616 free_netdev(ndev); in hns_nic_dev_remove()