Lines Matching defs:dev

45 #include <dev/mlx4/driver.h>
46 #include <dev/mlx4/device.h>
47 #include <dev/mlx4/cmd.h>
48 #include <dev/mlx4/cq.h>
64 struct net_device *dev = cq->dev;
65 struct mlx4_en_priv *priv = netdev_priv(dev);
75 done = mlx4_en_process_rx_cq(dev, cq, 4);
179 memcpy(spec_eth.eth.dst_mac, priv->dev->dev_addr, ETH_ALEN);
185 rc = mlx4_flow_detach(priv->mdev->dev, filter->reg_id);
190 rc = mlx4_flow_attach(priv->mdev->dev, &rule, &filter->reg_id);
256 rc = mlx4_flow_detach(priv->mdev->dev, filter->reg_id);
379 rps_may_expire_flow(priv->dev,
400 static void mlx4_en_vlan_rx_add_vid(void *arg, struct net_device *dev, u16 vid)
402 struct mlx4_en_priv *priv = netdev_priv(dev);
417 err = mlx4_SET_VLAN_FLTR(mdev->dev, priv);
421 if (mlx4_register_vlan(mdev->dev, priv->port, vid, &idx))
427 static void mlx4_en_vlan_rx_kill_vid(void *arg, struct net_device *dev, u16 vid)
429 struct mlx4_en_priv *priv = netdev_priv(dev);
442 mlx4_unregister_vlan(mdev->dev, priv->port, vid);
445 err = mlx4_SET_VLAN_FLTR(mdev->dev, priv);
458 if (priv->mdev->dev->caps.tunnel_offload_mode != MLX4_TUNNEL_OFFLOAD_MODE_VXLAN ||
459 priv->mdev->dev->caps.dmfs_high_steer_mode == MLX4_STEERING_DMFS_A0_STATIC)
462 err = mlx4_tunnel_steer_add(priv->mdev->dev, addr, priv->port, qpn,
476 struct mlx4_dev *dev = mdev->dev;
479 switch (dev->caps.steering_mode) {
488 err = mlx4_unicast_attach(dev, &qp, gid, 0, MLX4_PROT_ETH);
512 err = mlx4_flow_attach(dev, &rule, reg_id);
528 struct mlx4_dev *dev = mdev->dev;
530 switch (dev->caps.steering_mode) {
539 mlx4_unicast_detach(dev, &qp, gid, MLX4_PROT_ETH);
543 mlx4_flow_detach(dev, reg_id);
554 struct mlx4_dev *dev = mdev->dev;
558 u64 mac = mlx4_mac_to_u64(IF_LLADDR(priv->dev));
561 IF_LLADDR(priv->dev));
562 index = mlx4_register_mac(dev, priv->port, mac);
566 IF_LLADDR(priv->dev));
570 if (dev->caps.steering_mode == MLX4_STEERING_MODE_A0) {
571 int base_qpn = mlx4_get_base_qpn(dev, priv->port);
576 err = mlx4_qp_reserve_range(dev, 1, 1, qpn, MLX4_RESERVE_A0_QP);
580 mlx4_unregister_mac(dev, priv->port, mac);
590 struct mlx4_dev *dev = mdev->dev;
593 if (dev->caps.steering_mode == MLX4_STEERING_MODE_A0) {
594 u64 mac = mlx4_mac_to_u64(IF_LLADDR(priv->dev));
596 IF_LLADDR(priv->dev));
597 mlx4_unregister_mac(dev, priv->port, mac);
601 mlx4_qp_release_range(dev, qpn, 1);
606 static void mlx4_en_clear_uclist(struct net_device *dev)
608 struct mlx4_en_priv *priv = netdev_priv(dev);
617 static void mlx4_en_cache_uclist(struct net_device *dev)
619 struct mlx4_en_priv *priv = netdev_priv(dev);
623 mlx4_en_clear_uclist(dev);
625 if_addr_rlock(dev);
626 TAILQ_FOREACH(ifa, &dev->if_addrhead, ifa_link) {
641 if_addr_runlock(dev);
644 static void mlx4_en_clear_mclist(struct net_device *dev)
646 struct mlx4_en_priv *priv = netdev_priv(dev);
655 static void mlx4_en_cache_mclist(struct net_device *dev)
657 struct mlx4_en_priv *priv = netdev_priv(dev);
661 mlx4_en_clear_mclist(dev);
663 if_maddr_rlock(dev);
664 TAILQ_FOREACH(ifma, &dev->if_multiaddrs, ifma_link) {
679 if_maddr_runlock(dev);
731 static void mlx4_en_set_rx_mode(struct net_device *dev)
733 struct mlx4_en_priv *priv = netdev_priv(dev);
750 switch (mdev->dev->caps.steering_mode) {
752 err = mlx4_flow_steer_promisc_add(mdev->dev,
762 err = mlx4_unicast_promisc_add(mdev->dev,
772 err = mlx4_multicast_promisc_add(mdev->dev,
782 err = mlx4_SET_PORT_qpn_calc(mdev->dev,
792 err = mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, 0,
807 switch (mdev->dev->caps.steering_mode) {
809 err = mlx4_flow_steer_promisc_remove(mdev->dev,
818 err = mlx4_unicast_promisc_remove(mdev->dev,
825 err = mlx4_multicast_promisc_remove(mdev->dev,
835 err = mlx4_SET_PORT_qpn_calc(mdev->dev,
845 struct net_device *dev,
857 if (dev->if_flags & (IFF_ALLMULTI | IFF_PROMISC)) {
858 err = mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, 0,
865 switch (mdev->dev->caps.steering_mode) {
867 err = mlx4_flow_steer_promisc_add(mdev->dev,
874 err = mlx4_multicast_promisc_add(mdev->dev,
889 switch (mdev->dev->caps.steering_mode) {
891 err = mlx4_flow_steer_promisc_remove(mdev->dev,
897 err = mlx4_multicast_promisc_remove(mdev->dev,
910 err = mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, 0,
916 mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, ETH_BCAST,
921 mlx4_en_cache_mclist(dev);
924 mlx4_SET_MCAST_FLTR(mdev->dev, priv->port,
927 err = mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, 0,
939 err = mlx4_multicast_detach(mdev->dev,
948 err = mlx4_flow_detach(priv->mdev->dev, addr_list->tunnel_reg_id);
961 err = mlx4_multicast_attach(mdev->dev,
980 struct net_device *dev,
987 mlx4_en_cache_uclist(dev);
1014 struct net_device *dev = priv->dev;
1029 priv->dev->if_baudrate =
1034 if_link_state_change(priv->dev, LINK_STATE_UP);
1040 mlx4_en_do_unicast(priv, dev, mdev);
1043 if ((dev->if_flags & IFF_PROMISC) ||
1052 mlx4_en_do_multicast(priv, dev, mdev);
1088 (unsigned)priv->dev->if_mtu, priv->rx_frames, priv->rx_usecs);
1191 if (mlx4_is_slave(mdev->dev))
1237 if_link_state_change(priv->dev, LINK_STATE_DOWN);
1239 priv->dev->if_baudrate = 0;
1250 priv->dev->if_baudrate =
1253 if_link_state_change(priv->dev, LINK_STATE_UP);
1261 int mlx4_en_start_port(struct net_device *dev)
1263 struct mlx4_en_priv *priv = netdev_priv(dev);
1287 dev->if_mtu = min(dev->if_mtu, priv->max_mtu);
1288 mlx4_en_calc_rx_buf(dev);
1329 mlx4_get_default_counter_index(mdev->dev, priv->port);
1380 err = mlx4_SET_PORT_general(mdev->dev, priv->port,
1392 err = mlx4_SET_PORT_qpn_calc(mdev->dev, priv->port, priv->base_qpn, 0);
1400 err = mlx4_INIT_PORT(mdev->dev, priv->port);
1409 if (mlx4_multicast_attach(mdev->dev, &priv->rss_map.indir_qp, mc_list,
1423 dev->if_drv_flags &= ~IFF_DRV_OACTIVE;
1424 dev->if_drv_flags |= IFF_DRV_RUNNING;
1454 void mlx4_en_stop_port(struct net_device *dev)
1456 struct mlx4_en_priv *priv = netdev_priv(dev);
1472 mlx4_CLOSE_PORT(mdev->dev, priv->port);
1476 priv->counter_index = MLX4_SINK_COUNTER_INDEX(mdev->dev);
1479 if (mdev->dev->caps.steering_mode ==
1483 mlx4_flow_steer_promisc_remove(mdev->dev,
1486 mlx4_flow_steer_promisc_remove(mdev->dev,
1493 mlx4_unicast_promisc_remove(mdev->dev, priv->base_qpn,
1498 mlx4_multicast_promisc_remove(mdev->dev, priv->base_qpn,
1510 mlx4_en_clear_uclist(dev);
1519 mlx4_multicast_detach(mdev->dev, &priv->rss_map.indir_qp, mc_list,
1524 mlx4_multicast_detach(mdev->dev, &priv->rss_map.indir_qp,
1527 mlx4_en_clear_mclist(dev);
1534 mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, 0, 1, MLX4_MCAST_CONFIG);
1545 mlx4_en_free_tx_buf(dev, priv->tx_ring[i]);
1563 dev->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
1571 struct net_device *dev = priv->dev;
1595 mlx4_en_stop_port(dev);
1598 if (mlx4_en_start_port(dev))
1604 static void mlx4_en_clear_stats(struct net_device *dev)
1606 struct mlx4_en_priv *priv = netdev_priv(dev);
1610 if (!mlx4_is_slave(mdev->dev))
1638 struct net_device *dev;
1643 dev = priv->dev;
1654 mlx4_en_clear_stats(dev);
1656 err = mlx4_en_start_port(dev);
1670 if (priv->dev->rx_cpu_rmap) {
1671 free_irq_cpu_rmap(priv->dev->rx_cpu_rmap);
1672 priv->dev->rx_cpu_rmap = NULL;
1724 priv->dev->rx_cpu_rmap = alloc_irq_cpu_rmap(priv->rx_ring_num);
1725 if (!priv->dev->rx_cpu_rmap)
1763 void mlx4_en_destroy_netdev(struct net_device *dev)
1765 struct mlx4_en_priv *priv = netdev_priv(dev);
1782 mlx4_en_stop_port(dev);
1787 ether_ifdetach(dev);
1790 mlx4_free_hwq_res(mdev->dev, &priv->res, MLX4_EN_PAGE_SIZE);
1814 if_free(dev);
1818 static int mlx4_en_change_mtu(struct net_device *dev, int new_mtu)
1820 struct mlx4_en_priv *priv = netdev_priv(dev);
1825 (unsigned)dev->if_mtu, (unsigned)new_mtu);
1833 dev->if_mtu = new_mtu;
1834 if (dev->if_drv_flags & IFF_DRV_RUNNING) {
1840 mlx4_en_stop_port(dev);
1841 err = mlx4_en_start_port(dev);
1889 static void mlx4_en_media_status(struct ifnet *dev, struct ifmediareq *ifmr)
1893 priv = dev->if_softc;
1902 static int mlx4_en_media_change(struct ifnet *dev)
1910 priv = dev->if_softc;
1930 printf("%s: Only auto media type\n", if_name(dev));
1941 error = -mlx4_SET_PORT_general(priv->mdev->dev, priv->port,
1949 static int mlx4_en_ioctl(struct ifnet *dev, u_long command, caddr_t data)
1963 priv = dev->if_softc;
1974 error = -mlx4_en_change_mtu(dev, ifr->ifr_mtu);
1977 if (dev->if_flags & IFF_UP) {
1978 if ((dev->if_drv_flags & IFF_DRV_RUNNING) == 0) {
1980 mlx4_en_start_port(dev);
1983 mlx4_en_set_rx_mode(dev);
1987 if (dev->if_drv_flags & IFF_DRV_RUNNING) {
1988 mlx4_en_stop_port(dev);
1989 if_link_state_change(dev, LINK_STATE_DOWN);
1996 mlx4_en_set_rx_mode(dev);
2000 error = ifmedia_ioctl(dev, ifr, &priv->media, command);
2004 mask = ifr->ifr_reqcap ^ dev->if_capenable;
2006 dev->if_capenable ^= IFCAP_TXCSUM;
2007 dev->if_hwassist ^= (CSUM_TCP | CSUM_UDP | CSUM_IP);
2009 if (IFCAP_TSO4 & dev->if_capenable &&
2010 !(IFCAP_TXCSUM & dev->if_capenable)) {
2012 dev->if_capenable &= ~IFCAP_TSO4;
2013 dev->if_hwassist &= ~CSUM_IP_TSO;
2014 if_printf(dev,
2019 dev->if_capenable ^= IFCAP_TXCSUM_IPV6;
2020 dev->if_hwassist ^= (CSUM_UDP_IPV6 | CSUM_TCP_IPV6);
2022 if (IFCAP_TSO6 & dev->if_capenable &&
2023 !(IFCAP_TXCSUM_IPV6 & dev->if_capenable)) {
2025 dev->if_capenable &= ~IFCAP_TSO6;
2026 dev->if_hwassist &= ~CSUM_IP6_TSO;
2027 if_printf(dev,
2032 dev->if_capenable ^= IFCAP_RXCSUM;
2034 dev->if_capenable ^= IFCAP_RXCSUM_IPV6;
2037 if (!(IFCAP_TSO4 & dev->if_capenable) &&
2038 !(IFCAP_TXCSUM & dev->if_capenable)) {
2039 if_printf(dev, "enable txcsum first.\n");
2043 dev->if_capenable ^= IFCAP_TSO4;
2044 dev->if_hwassist ^= CSUM_IP_TSO;
2047 if (!(IFCAP_TSO6 & dev->if_capenable) &&
2048 !(IFCAP_TXCSUM_IPV6 & dev->if_capenable)) {
2049 if_printf(dev, "enable txcsum6 first.\n");
2053 dev->if_capenable ^= IFCAP_TSO6;
2054 dev->if_hwassist ^= CSUM_IP6_TSO;
2057 dev->if_capenable ^= IFCAP_LRO;
2059 dev->if_capenable ^= IFCAP_VLAN_HWTAGGING;
2061 dev->if_capenable ^= IFCAP_VLAN_HWFILTER;
2063 dev->if_capenable ^= IFCAP_WOL_MAGIC;
2064 if (dev->if_drv_flags & IFF_DRV_RUNNING)
2065 mlx4_en_start_port(dev);
2068 VLAN_CAPABILITIES(dev);
2085 error = mlx4_get_module_info(mdev->dev, priv->port,
2129 error = ether_ioctl(dev, command, data);
2140 struct net_device *dev;
2147 dev = priv->dev = if_alloc(IFT_ETHER);
2148 if (dev == NULL) {
2153 dev->if_softc = priv;
2154 if_initname(dev, "mlxen", (device_get_unit(
2155 mdev->pdev->dev.bsddev) * MLX4_MAX_PORTS) + port - 1);
2156 dev->if_mtu = ETHERMTU;
2157 dev->if_init = mlx4_en_open;
2158 dev->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
2159 dev->if_ioctl = mlx4_en_ioctl;
2160 dev->if_transmit = mlx4_en_transmit;
2161 dev->if_qflush = mlx4_en_qflush;
2162 dev->if_snd.ifq_maxlen = prof->tx_ring_size;
2181 priv->dev = dev;
2183 priv->ddev = &mdev->pdev->dev;
2205 priv->cqe_factor = (mdev->dev->caps.cqe_size == 64) ? 1 : 0;
2211 if (!mlx4_is_slave(priv->mdev->dev)) {
2214 if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ETS_CFG) {
2215 dev->dcbnl_ops = &mlx4_en_dcbnl_ops;
2218 dev->dcbnl_ops = &mlx4_en_dcbnl_pfc_ops;
2224 priv->max_mtu = mdev->dev->caps.eth_mtu_cap[priv->port];
2225 priv->mac = mdev->dev->caps.def_mac[priv->port];
2245 err = mlx4_alloc_hwq_res(mdev->dev, &priv->res,
2256 dev->if_capabilities |= IFCAP_HWCSUM | IFCAP_HWCSUM_IPV6;
2257 dev->if_capabilities |= IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING;
2258 dev->if_capabilities |= IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWFILTER;
2259 dev->if_capabilities |= IFCAP_LINKSTATE | IFCAP_JUMBO_MTU;
2260 dev->if_capabilities |= IFCAP_LRO;
2261 dev->if_capabilities |= IFCAP_HWSTATS;
2264 dev->if_capabilities |= IFCAP_TSO4 | IFCAP_TSO6 | IFCAP_VLAN_HWTSO;
2268 dev->if_hw_tsomax = MLX4_EN_TX_MAX_PAYLOAD_SIZE - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN) /* hdr */;
2269 dev->if_hw_tsomaxsegcount = MLX4_EN_TX_MAX_MBUF_FRAGS - 1 /* hdr */;
2270 dev->if_hw_tsomaxsegsize = MLX4_EN_TX_MAX_MBUF_SIZE;
2273 dev->if_capenable = dev->if_capabilities;
2275 dev->if_hwassist = 0;
2276 if (dev->if_capenable & (IFCAP_TSO4 | IFCAP_TSO6))
2277 dev->if_hwassist |= CSUM_TSO;
2278 if (dev->if_capenable & IFCAP_TXCSUM)
2279 dev->if_hwassist |= (CSUM_TCP | CSUM_UDP | CSUM_IP);
2280 if (dev->if_capenable & IFCAP_TXCSUM_IPV6)
2281 dev->if_hwassist |= (CSUM_UDP_IPV6 | CSUM_TCP_IPV6);
2290 mdev->pndev[priv->port] = dev;
2300 ether_ifattach(dev, dev_addr);
2301 if_link_state_change(dev, LINK_STATE_DOWN);
2320 priv->rx_mb_size = dev->if_mtu + ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN;
2321 err = mlx4_SET_PORT_general(mdev->dev, priv->port,
2333 err = mlx4_INIT_PORT(mdev->dev, priv->port);
2341 if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_TS)
2347 mlx4_en_destroy_netdev(dev);
2351 static int mlx4_en_set_ring_size(struct net_device *dev,
2354 struct mlx4_en_priv *priv = netdev_priv(dev);
2373 mlx4_en_stop_port(dev);
2384 err = mlx4_en_start_port(dev);
2403 error = -mlx4_en_set_ring_size(priv->dev, size,
2419 error = -mlx4_en_set_ring_size(priv->dev, priv->prof->rx_ring_size,
2425 static int mlx4_en_get_module_info(struct net_device *dev,
2428 struct mlx4_en_priv *priv = netdev_priv(dev);
2434 ret = mlx4_get_module_info(mdev->dev, priv->port,
2472 static int mlx4_en_get_module_eeprom(struct net_device *dev,
2476 struct mlx4_en_priv *priv = netdev_priv(dev);
2491 ret = mlx4_get_module_info(mdev->dev, priv->port,
2540 struct net_device *dev;
2550 dev = priv->dev;
2553 error = mlx4_en_get_module_info(dev, &modinfo);
2564 error = mlx4_en_get_module_eeprom(dev, &ee, data);
2595 error = -mlx4_SET_PORT_general(priv->mdev->dev, priv->port,
2627 mlx4_en_stop_port(priv->dev);
2635 error = -mlx4_en_start_port(priv->dev);
2644 error = -mlx4_SET_PORT_general(priv->mdev->dev, priv->port,
2656 struct net_device *dev;
2663 dev = priv->dev;
2665 pnameunit = device_get_nameunit(priv->mdev->pdev->dev.bsddev);
2669 OID_AUTO, dev->if_xname, CTLFLAG_RD, 0, "mlx4 10gig ethernet");