mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
wilc1000: added 'ndo_set_mac_address' callback support
Added support for 'ndo_set_mac_address call' callback to allow change of interface MAC address. Signed-off-by: Ajay Singh <ajay.kathat@microchip.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20201125114059.10006-2-ajay.kathat@microchip.com
This commit is contained in:
parent
75729e110e
commit
c04fabacb7
3 changed files with 56 additions and 0 deletions
|
@ -1276,6 +1276,23 @@ int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int wilc_set_mac_address(struct wilc_vif *vif, u8 *mac_addr)
|
||||||
|
{
|
||||||
|
struct wid wid;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
wid.id = WID_MAC_ADDR;
|
||||||
|
wid.type = WID_STR;
|
||||||
|
wid.size = ETH_ALEN;
|
||||||
|
wid.val = mac_addr;
|
||||||
|
|
||||||
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
||||||
|
if (result)
|
||||||
|
netdev_err(vif->ndev, "Failed to get mac address\n");
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies,
|
int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies,
|
||||||
size_t ies_len)
|
size_t ies_len)
|
||||||
{
|
{
|
||||||
|
|
|
@ -168,6 +168,7 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
|
||||||
u8 cipher_mode);
|
u8 cipher_mode);
|
||||||
int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid);
|
int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid);
|
||||||
int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr);
|
int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr);
|
||||||
|
int wilc_set_mac_address(struct wilc_vif *vif, u8 *mac_addr);
|
||||||
int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies,
|
int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies,
|
||||||
size_t ies_len);
|
size_t ies_len);
|
||||||
int wilc_disconnect(struct wilc_vif *vif);
|
int wilc_disconnect(struct wilc_vif *vif);
|
||||||
|
|
|
@ -628,6 +628,43 @@ static struct net_device_stats *mac_stats(struct net_device *dev)
|
||||||
return &vif->netstats;
|
return &vif->netstats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int wilc_set_mac_addr(struct net_device *dev, void *p)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
struct wilc_vif *vif = netdev_priv(dev);
|
||||||
|
struct wilc *wilc = vif->wilc;
|
||||||
|
struct sockaddr *addr = (struct sockaddr *)p;
|
||||||
|
unsigned char mac_addr[ETH_ALEN];
|
||||||
|
struct wilc_vif *tmp_vif;
|
||||||
|
int srcu_idx;
|
||||||
|
|
||||||
|
if (!is_valid_ether_addr(addr->sa_data))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
srcu_idx = srcu_read_lock(&wilc->srcu);
|
||||||
|
list_for_each_entry_rcu(tmp_vif, &wilc->vif_list, list) {
|
||||||
|
wilc_get_mac_address(tmp_vif, mac_addr);
|
||||||
|
if (ether_addr_equal(addr->sa_data, mac_addr)) {
|
||||||
|
if (vif != tmp_vif) {
|
||||||
|
srcu_read_unlock(&wilc->srcu, srcu_idx);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
srcu_read_unlock(&wilc->srcu, srcu_idx);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
srcu_read_unlock(&wilc->srcu, srcu_idx);
|
||||||
|
|
||||||
|
result = wilc_set_mac_address(vif, (u8 *)addr->sa_data);
|
||||||
|
if (result)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
ether_addr_copy(vif->bssid, addr->sa_data);
|
||||||
|
ether_addr_copy(vif->ndev->dev_addr, addr->sa_data);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static void wilc_set_multicast_list(struct net_device *dev)
|
static void wilc_set_multicast_list(struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct netdev_hw_addr *ha;
|
struct netdev_hw_addr *ha;
|
||||||
|
@ -813,6 +850,7 @@ static const struct net_device_ops wilc_netdev_ops = {
|
||||||
.ndo_init = mac_init_fn,
|
.ndo_init = mac_init_fn,
|
||||||
.ndo_open = wilc_mac_open,
|
.ndo_open = wilc_mac_open,
|
||||||
.ndo_stop = wilc_mac_close,
|
.ndo_stop = wilc_mac_close,
|
||||||
|
.ndo_set_mac_address = wilc_set_mac_addr,
|
||||||
.ndo_start_xmit = wilc_mac_xmit,
|
.ndo_start_xmit = wilc_mac_xmit,
|
||||||
.ndo_get_stats = mac_stats,
|
.ndo_get_stats = mac_stats,
|
||||||
.ndo_set_rx_mode = wilc_set_multicast_list,
|
.ndo_set_rx_mode = wilc_set_multicast_list,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue