Skip to content

Commit

Permalink
net: hns: add get_coalesce_range api for hns
Browse files Browse the repository at this point in the history
This patch adds get_coalesce_range api for hns, it shows
range of coalesce usecs and frames that can be set on
this interface.

Signed-off-by: Daode Huang <huangdaode@hisilicon.com>
Signed-off-by: Yisen Zhuang <Yisen.Zhuang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Daode Huang authored and David S. Miller committed Jun 21, 2016
1 parent f56c1b3 commit ad59a17
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/net/ethernet/hisilicon/hns/hnae.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,11 @@ struct hnae_ae_ops {
int (*set_coalesce_usecs)(struct hnae_handle *handle, u32 timeout);
int (*set_coalesce_frames)(struct hnae_handle *handle,
u32 coalesce_frames);
void (*get_coalesce_range)(struct hnae_handle *handle,
u32 *tx_frames_low, u32 *rx_frames_low,
u32 *tx_frames_high, u32 *rx_frames_high,
u32 *tx_usecs_low, u32 *rx_usecs_low,
u32 *tx_usecs_high, u32 *rx_usecs_high);
void (*set_promisc_mode)(struct hnae_handle *handle, u32 en);
int (*get_mac_addr)(struct hnae_handle *handle, void **p);
int (*set_mac_addr)(struct hnae_handle *handle, void *p);
Expand Down
25 changes: 25 additions & 0 deletions drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,30 @@ static int hns_ae_set_coalesce_frames(struct hnae_handle *handle,
ring_pair->port_id_in_comm, coalesce_frames);
}

static void hns_ae_get_coalesce_range(struct hnae_handle *handle,
u32 *tx_frames_low, u32 *rx_frames_low,
u32 *tx_frames_high, u32 *rx_frames_high,
u32 *tx_usecs_low, u32 *rx_usecs_low,
u32 *tx_usecs_high, u32 *rx_usecs_high)
{
struct dsaf_device *dsaf_dev;

dsaf_dev = hns_ae_get_dsaf_dev(handle->dev);

*tx_frames_low = HNS_RCB_MIN_COALESCED_FRAMES;
*rx_frames_low = HNS_RCB_MIN_COALESCED_FRAMES;
*tx_frames_high =
(dsaf_dev->desc_num - 1 > HNS_RCB_MAX_COALESCED_FRAMES) ?
HNS_RCB_MAX_COALESCED_FRAMES : dsaf_dev->desc_num - 1;
*rx_frames_high =
(dsaf_dev->desc_num - 1 > HNS_RCB_MAX_COALESCED_FRAMES) ?
HNS_RCB_MAX_COALESCED_FRAMES : dsaf_dev->desc_num - 1;
*tx_usecs_low = 0;
*rx_usecs_low = 0;
*tx_usecs_high = HNS_RCB_MAX_COALESCED_USECS;
*rx_usecs_high = HNS_RCB_MAX_COALESCED_USECS;
}

void hns_ae_update_stats(struct hnae_handle *handle,
struct net_device_stats *net_stats)
{
Expand Down Expand Up @@ -798,6 +822,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
.get_rx_max_coalesced_frames = hns_ae_get_rx_max_coalesced_frames,
.set_coalesce_usecs = hns_ae_set_coalesce_usecs,
.set_coalesce_frames = hns_ae_set_coalesce_frames,
.get_coalesce_range = hns_ae_get_coalesce_range,
.set_promisc_mode = hns_ae_set_promisc_mode,
.set_mac_addr = hns_ae_set_mac_address,
.set_mc_addr = hns_ae_set_multicast_one,
Expand Down
10 changes: 10 additions & 0 deletions drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,16 @@ static int hns_get_coalesce(struct net_device *net_dev,
&ec->tx_max_coalesced_frames,
&ec->rx_max_coalesced_frames);

ops->get_coalesce_range(priv->ae_handle,
&ec->tx_max_coalesced_frames_low,
&ec->rx_max_coalesced_frames_low,
&ec->tx_max_coalesced_frames_high,
&ec->rx_max_coalesced_frames_high,
&ec->tx_coalesce_usecs_low,
&ec->rx_coalesce_usecs_low,
&ec->tx_coalesce_usecs_high,
&ec->rx_coalesce_usecs_high);

return 0;
}

Expand Down

0 comments on commit ad59a17

Please sign in to comment.