Skip to content

Commit

Permalink
Merge branch 'hns3-next'
Browse files Browse the repository at this point in the history
Salil Mehta says:

====================
Misc. bug fixes & optimizations for HNS3 driver

This patch-set presents some bug fixes found out during the internal
review and system testing and some small optimizations.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jun 1, 2018
2 parents 07f7ee6 + 3a678b5 commit 21ad117
Show file tree
Hide file tree
Showing 9 changed files with 441 additions and 51 deletions.
2 changes: 2 additions & 0 deletions drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ enum hclge_mbx_mac_vlan_subcode {
HCLGE_MBX_MAC_VLAN_MC_ADD, /* add new MC mac addr */
HCLGE_MBX_MAC_VLAN_MC_REMOVE, /* remove MC mac addr */
HCLGE_MBX_MAC_VLAN_MC_FUNC_MTA_ENABLE, /* config func MTA enable */
HCLGE_MBX_MAC_VLAN_MTA_TYPE_READ, /* read func MTA type */
HCLGE_MBX_MAC_VLAN_MTA_STATUS_UPDATE, /* update MTA status */
};

/* below are per-VF vlan cfg subcodes */
Expand Down
4 changes: 3 additions & 1 deletion drivers/net/ethernet/hisilicon/hns3/hnae3.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ struct hnae3_ae_ops {
int (*set_loopback)(struct hnae3_handle *handle,
enum hnae3_loop loop_mode, bool en);

void (*set_promisc_mode)(struct hnae3_handle *handle, u32 en);
void (*set_promisc_mode)(struct hnae3_handle *handle, bool en_uc_pmc,
bool en_mc_pmc);
int (*set_mtu)(struct hnae3_handle *handle, int new_mtu);

void (*get_pauseparam)(struct hnae3_handle *handle,
Expand Down Expand Up @@ -352,6 +353,7 @@ struct hnae3_ae_ops {
const unsigned char *addr);
int (*rm_mc_addr)(struct hnae3_handle *handle,
const unsigned char *addr);
int (*update_mta_status)(struct hnae3_handle *handle);

void (*set_tso_stats)(struct hnae3_handle *handle, int enable);
void (*update_stats)(struct hnae3_handle *handle,
Expand Down
60 changes: 57 additions & 3 deletions drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,15 +415,21 @@ static void hns3_nic_set_rx_mode(struct net_device *netdev)

if (h->ae_algo->ops->set_promisc_mode) {
if (netdev->flags & IFF_PROMISC)
h->ae_algo->ops->set_promisc_mode(h, 1);
h->ae_algo->ops->set_promisc_mode(h, true, true);
else if (netdev->flags & IFF_ALLMULTI)
h->ae_algo->ops->set_promisc_mode(h, false, true);
else
h->ae_algo->ops->set_promisc_mode(h, 0);
h->ae_algo->ops->set_promisc_mode(h, false, false);
}
if (__dev_uc_sync(netdev, hns3_nic_uc_sync, hns3_nic_uc_unsync))
netdev_err(netdev, "sync uc address fail\n");
if (netdev->flags & IFF_MULTICAST)
if (netdev->flags & IFF_MULTICAST) {
if (__dev_mc_sync(netdev, hns3_nic_mc_sync, hns3_nic_mc_unsync))
netdev_err(netdev, "sync mc address fail\n");

if (h->ae_algo->ops->update_mta_status)
h->ae_algo->ops->update_mta_status(h);
}
}

static int hns3_set_tso(struct sk_buff *skb, u32 *paylen,
Expand Down Expand Up @@ -653,6 +659,32 @@ static void hns3_set_l2l3l4_len(struct sk_buff *skb, u8 ol4_proto,
}
}

/* when skb->encapsulation is 0, skb->ip_summed is CHECKSUM_PARTIAL
* and it is udp packet, which has a dest port as the IANA assigned.
* the hardware is expected to do the checksum offload, but the
* hardware will not do the checksum offload when udp dest port is
* 4789.
*/
static bool hns3_tunnel_csum_bug(struct sk_buff *skb)
{
#define IANA_VXLAN_PORT 4789
union {
struct tcphdr *tcp;
struct udphdr *udp;
struct gre_base_hdr *gre;
unsigned char *hdr;
} l4;

l4.hdr = skb_transport_header(skb);

if (!(!skb->encapsulation && l4.udp->dest == htons(IANA_VXLAN_PORT)))
return false;

skb_checksum_help(skb);

return true;
}

static int hns3_set_l3l4_type_csum(struct sk_buff *skb, u8 ol4_proto,
u8 il4_proto, u32 *type_cs_vlan_tso,
u32 *ol_type_vlan_len_msec)
Expand Down Expand Up @@ -741,6 +773,9 @@ static int hns3_set_l3l4_type_csum(struct sk_buff *skb, u8 ol4_proto,
HNS3_L4T_TCP);
break;
case IPPROTO_UDP:
if (hns3_tunnel_csum_bug(skb))
break;

hnae_set_field(*type_cs_vlan_tso,
HNS3_TXD_L4T_M,
HNS3_TXD_L4T_S,
Expand Down Expand Up @@ -1130,6 +1165,12 @@ static int hns3_nic_net_set_mac_address(struct net_device *netdev, void *p)
if (!mac_addr || !is_valid_ether_addr((const u8 *)mac_addr->sa_data))
return -EADDRNOTAVAIL;

if (ether_addr_equal(netdev->dev_addr, mac_addr->sa_data)) {
netdev_info(netdev, "already using mac address %pM\n",
mac_addr->sa_data);
return 0;
}

ret = h->ae_algo->ops->set_mac_addr(h, mac_addr->sa_data, false);
if (ret) {
netdev_err(netdev, "set_mac_address fail, ret=%d!\n", ret);
Expand Down Expand Up @@ -2999,6 +3040,15 @@ static void hns3_init_mac_addr(struct net_device *netdev, bool init)

}

static void hns3_uninit_mac_addr(struct net_device *netdev)
{
struct hns3_nic_priv *priv = netdev_priv(netdev);
struct hnae3_handle *h = priv->ae_handle;

if (h->ae_algo->ops->rm_uc_addr)
h->ae_algo->ops->rm_uc_addr(h, netdev->dev_addr);
}

static void hns3_nic_set_priv_ops(struct net_device *netdev)
{
struct hns3_nic_priv *priv = netdev_priv(netdev);
Expand Down Expand Up @@ -3127,6 +3177,8 @@ static void hns3_client_uninit(struct hnae3_handle *handle, bool reset)

priv->ring_data = NULL;

hns3_uninit_mac_addr(netdev);

free_netdev(netdev);
}

Expand Down Expand Up @@ -3443,6 +3495,8 @@ static int hns3_reset_notify_uninit_enet(struct hnae3_handle *handle)

priv->ring_data = NULL;

hns3_uninit_mac_addr(netdev);

return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static int hns3_lp_setup(struct net_device *ndev, enum hnae3_loop loop, bool en)
if (ret)
return ret;

h->ae_algo->ops->set_promisc_mode(h, en);
h->ae_algo->ops->set_promisc_mode(h, en, en);

return ret;
}
Expand Down
Loading

0 comments on commit 21ad117

Please sign in to comment.