static int nic_set_mac_addr(struct net_device *netdev, void *addr) { struct nic_priv *priv = netdev_priv(netdev); netif_info(priv, drv, netdev, "%s(#%d), priv:%p\n", __func__, __LINE__, priv); return eth_mac_addr(netdev, addr); }
static int netvsc_set_mac_addr(struct net_device *ndev, void *p) { struct net_device_context *ndevctx = netdev_priv(ndev); struct hv_device *hdev = ndevctx->device_ctx; struct sockaddr *addr = p; char save_adr[ETH_ALEN]; unsigned char save_aatype; int err; memcpy(save_adr, ndev->dev_addr, ETH_ALEN); save_aatype = ndev->addr_assign_type; err = eth_mac_addr(ndev, p); if (err != 0) return err; err = rndis_filter_set_device_mac(hdev, addr->sa_data); if (err != 0) { /* roll back to saved MAC */ memcpy(ndev->dev_addr, save_adr, ETH_ALEN); ndev->addr_assign_type = save_aatype; } return err; }
/* opa_vnic_process_vema_config - process vema configuration updates */ void opa_vnic_process_vema_config(struct opa_vnic_adapter *adapter) { struct __opa_veswport_info *info = &adapter->info; struct rdma_netdev *rn = netdev_priv(adapter->netdev); u8 port_num[OPA_VESW_MAX_NUM_DEF_PORT] = { 0 }; struct net_device *netdev = adapter->netdev; u8 i, port_count = 0; u16 port_mask; /* If the base_mac_addr is changed, update the interface mac address */ if (memcmp(info->vport.base_mac_addr, adapter->vema_mac_addr, ARRAY_SIZE(info->vport.base_mac_addr))) { struct sockaddr saddr; memcpy(saddr.sa_data, info->vport.base_mac_addr, ARRAY_SIZE(info->vport.base_mac_addr)); mutex_lock(&adapter->lock); eth_mac_addr(netdev, &saddr); memcpy(adapter->vema_mac_addr, info->vport.base_mac_addr, ETH_ALEN); mutex_unlock(&adapter->lock); } rn->set_id(netdev, info->vesw.vesw_id); /* Handle MTU limit change */ rtnl_lock(); netdev->max_mtu = max_t(unsigned int, info->vesw.eth_mtu_non_vlan, netdev->min_mtu); if (netdev->mtu > netdev->max_mtu) dev_set_mtu(netdev, netdev->max_mtu); rtnl_unlock(); /* Update flow to default port redirection table */ port_mask = info->vesw.def_port_mask; for (i = 0; i < OPA_VESW_MAX_NUM_DEF_PORT; i++) { if (port_mask & 1) port_num[port_count++] = i; port_mask >>= 1; } /* * Build the flow table. Flow table is required when destination LID * is not available. Up to OPA_VNIC_FLOW_TBL_SIZE flows supported. * Each flow need a default port number to get its dlid from the * u_ucast_dlid array. */ for (i = 0; i < OPA_VNIC_FLOW_TBL_SIZE; i++) adapter->flow_tbl[i] = port_count ? port_num[i % port_count] : OPA_VNIC_INVALID_PORT; /* Operational state can only be DROP_ALL or FORWARDING */ if (info->vport.config_state == OPA_VNIC_STATE_FORWARDING) { info->vport.oper_state = OPA_VNIC_STATE_FORWARDING; netif_dormant_off(netdev); } else { info->vport.oper_state = OPA_VNIC_STATE_DROP_ALL; netif_dormant_on(netdev); } }
/** * cvm_oct_common_set_mac_address - set the hardware MAC address for a device * @dev: The device in question. * @addr: Socket address. * * Returns Zero on success */ static int cvm_oct_common_set_mac_address(struct net_device *dev, void *addr) { int r = eth_mac_addr(dev, addr); if (r) return r; return cvm_oct_set_mac_filter(dev); }
static int octeon_mgmt_set_mac_address(struct net_device *netdev, void *addr) { int r = eth_mac_addr(netdev, addr); if (r) return r; octeon_mgmt_set_rx_filtering(netdev); return 0; }
static int xge_set_mac_addr(struct net_device *ndev, void *addr) { struct xge_pdata *pdata = netdev_priv(ndev); int ret; ret = eth_mac_addr(ndev, addr); if (ret) return ret; xge_mac_set_station_addr(pdata); return 0; }
static int aqc111_set_mac_addr(struct net_device *net, void *p) { struct usbnet *dev = netdev_priv(net); int ret = 0; ret = eth_mac_addr(net, p); if (ret < 0) return ret; /* Set the MAC address */ return aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_NODE_ID, ETH_ALEN, ETH_ALEN, net->dev_addr); }
/** * nps_enet_set_mac_address - Set the MAC address for this device. * @ndev: Pointer to net_device structure. * @p: 6 byte Address to be written as MAC address. * * This function copies the HW address from the sockaddr structure to the * net_device structure and updates the address in HW. * * returns: -EBUSY if the net device is busy or 0 if the address is set * successfully. */ static s32 nps_enet_set_mac_address(struct net_device *ndev, void *p) { struct sockaddr *addr = p; s32 res; if (netif_running(ndev)) return -EBUSY; res = eth_mac_addr(ndev, p); if (!res) { ether_addr_copy(ndev->dev_addr, addr->sa_data); nps_enet_set_hw_mac_address(ndev); } return res; }
static int most_nd_set_mac_address(struct net_device *dev, void *p) { struct net_dev_context *nd = netdev_priv(dev); int err = eth_mac_addr(dev, p); if (err) return err; nd->is_mamac = (dev->dev_addr[0] == 0 && dev->dev_addr[1] == 0 && dev->dev_addr[2] == 0 && dev->dev_addr[3] == 0); /* * Set default MTU for the given packet type. * It is still possible to change MTU using ip tools afterwards. */ dev->mtu = nd->is_mamac ? MAMAC_DATA_LEN : ETH_DATA_LEN; return 0; }
/* opa_vnic_set_mac_addr - change mac address */ static int opa_vnic_set_mac_addr(struct net_device *netdev, void *addr) { struct opa_vnic_adapter *adapter = opa_vnic_priv(netdev); struct sockaddr *sa = addr; int rc; if (!memcmp(netdev->dev_addr, sa->sa_data, ETH_ALEN)) return 0; mutex_lock(&adapter->lock); rc = eth_mac_addr(netdev, addr); mutex_unlock(&adapter->lock); if (rc) return rc; adapter->info.vport.uc_macs_gen_count++; opa_vnic_vema_report_event(adapter, OPA_VESWPORT_TRAP_IFACE_UCAST_MAC_CHANGE); return 0; }
/***************************************************************************** 函 数 名 : uip_main 功能描述 : uip main looplock function 输入参数 : void 输出参数 : 无 返 回 值 : 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2017年4月17日 作 者 : QSWWD 修改内容 : 新生成函数 *****************************************************************************/ void uip_main(void) { int i; uip_ipaddr_t ipaddr; struct timer periodic_timer, arp_timer; timer_set(&periodic_timer, CLOCK_SECOND / 2); timer_set(&arp_timer, CLOCK_SECOND * 10); uip_init(); uip_ipaddr(ipaddr, 192,168,1,6); uip_sethostaddr(ipaddr); uip_ipaddr(ipaddr, 192,168,1,1); uip_setdraddr(ipaddr); uip_ipaddr(ipaddr, 255,255,255,0); uip_setnetmask(ipaddr); /*MAC*/ memcpy(&uip_ethaddr,eth_mac_addr(),6); /*app initialize*/ uip_app_init(); //main loop while(1) { uip_len = tapdev_read(uip_buf); if(uip_len > 0) { if(BUF->type == htons(UIP_ETHTYPE_IP)) { uip_arp_ipin(); uip_input(); /* If the above function invocation resulted in data that should be sent out on the network, the global variable uip_len is set to a value > 0. */ if(uip_len > 0) { uip_arp_out(); tapdev_send(uip_buf,uip_len); } } else if(BUF->type == htons(UIP_ETHTYPE_ARP)) { uip_arp_arpin(); /* If the above function invocation resulted in data that should be sent out on the network, the global variable uip_len is set to a value > 0. */ if(uip_len > 0) { tapdev_send(uip_buf,uip_len); } } } else if(timer_expired(&periodic_timer)) { timer_reset(&periodic_timer); for(i = 0; i < UIP_CONNS; i++) { uip_periodic(i); /* If the above function invocation resulted in data that should be sent out on the network, the global variable uip_len is set to a value > 0. */ if(uip_len > 0) { uip_arp_out(); tapdev_send(uip_buf,uip_len); } } #if UIP_UDP for(i = 0; i < UIP_UDP_CONNS; i++) { uip_udp_periodic(i); /* If the above function invocation resulted in data that should be sent out on the network, the global variable uip_len is set to a value > 0. */ if(uip_len > 0) { uip_arp_out(); tapdev_send(uip_buf,uip_len); } } #endif /* UIP_UDP */ /* Call the ARP timer function every 10 seconds. */ if(timer_expired(&arp_timer)) { timer_reset(&arp_timer); uip_arp_timer(); } } } }
static int hip04_set_mac_address(struct net_device *ndev, void *addr) { eth_mac_addr(ndev, addr); hip04_update_mac_address(ndev); return 0; }