From: Govindarajulu Varadarajan <_govind@gmx.com>
To: davem@davemloft.net, netdev@vger.kernel.org
Cc: ssujith@cisco.com, benve@cisco.com, edumazet@google.com,
ben@decadent.org.uk, Govindarajulu Varadarajan <_govind@gmx.com>
Subject: [PATCH net-next 4/4] enic: add ethtool support for changing alloc order
Date: Sat, 31 Jan 2015 17:58:10 +0530 [thread overview]
Message-ID: <1422707290-939-5-git-send-email-_govind@gmx.com> (raw)
In-Reply-To: <1422707290-939-1-git-send-email-_govind@gmx.com>
Adds support for changing page order of enic frag allocator.
In case of changing mtu, if size of new mtu is greater than size of compound
page allocated in enic frag allocator, we change the order to min order required
for the new mtu. We would like to give high priority for changing mtu than order
value.
Signed-off-by: Govindarajulu Varadarajan <_govind@gmx.com>
---
drivers/net/ethernet/cisco/enic/enic_ethtool.c | 15 +++++++++++++++
drivers/net/ethernet/cisco/enic/enic_main.c | 18 ++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/drivers/net/ethernet/cisco/enic/enic_ethtool.c b/drivers/net/ethernet/cisco/enic/enic_ethtool.c
index 3f9d91b..e29423c 100644
--- a/drivers/net/ethernet/cisco/enic/enic_ethtool.c
+++ b/drivers/net/ethernet/cisco/enic/enic_ethtool.c
@@ -18,6 +18,7 @@
#include <linux/netdevice.h>
#include <linux/ethtool.h>
+#include <linux/if_vlan.h>
#include "enic_res.h"
#include "enic.h"
@@ -409,6 +410,9 @@ static int enic_get_tunable(struct net_device *dev,
case ETHTOOL_RX_COPYBREAK:
*(u32 *)data = enic->rx_copybreak;
break;
+ case ETHTOOL_RX_ALLOC_ORDER:
+ *(u8 *)data = enic->alloc_order;
+ break;
default:
ret = -EINVAL;
break;
@@ -428,6 +432,17 @@ static int enic_set_tunable(struct net_device *dev,
case ETHTOOL_RX_COPYBREAK:
enic->rx_copybreak = *(u32 *)data;
break;
+ case ETHTOOL_RX_ALLOC_ORDER:
+ ret = dev->mtu + VLAN_ETH_HLEN + NET_IP_ALIGN + NET_SKB_PAD;
+ ret = SKB_DATA_ALIGN(ret) +
+ SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
+ if (*(u8 *)data < get_order(ret)) {
+ ret = -EINVAL;
+ break;
+ }
+ ret = 0;
+ enic->alloc_order = *(u8 *)data;
+ break;
default:
ret = -EINVAL;
break;
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index f15687d..4a759a0 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -1872,7 +1872,11 @@ static int enic_change_mtu(struct net_device *netdev, int new_mtu)
{
struct enic *enic = netdev_priv(netdev);
int running = netif_running(netdev);
+ size_t len;
+ len = new_mtu + VLAN_ETH_HLEN + NET_IP_ALIGN + NET_SKB_PAD;
+ len = SKB_DATA_ALIGN(len) +
+ SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
if (new_mtu < ENIC_MIN_MTU || new_mtu > ENIC_MAX_MTU)
return -EINVAL;
@@ -1884,6 +1888,11 @@ static int enic_change_mtu(struct net_device *netdev, int new_mtu)
netdev->mtu = new_mtu;
+ if (len > (PAGE_SIZE << enic->alloc_order)) {
+ enic->alloc_order = get_order(len);
+ netdev_warn(netdev, "new mtu is greater than size of rx alloc_page, resetting enic->alloc_order to :%d\n",
+ enic->alloc_order);
+ }
if (netdev->mtu > enic->port_mtu)
netdev_warn(netdev,
"interface MTU (%d) set higher than port MTU (%d)\n",
@@ -1902,8 +1911,12 @@ static void enic_change_mtu_work(struct work_struct *work)
int new_mtu = vnic_dev_mtu(enic->vdev);
int err;
unsigned int i;
+ size_t len;
new_mtu = max_t(int, ENIC_MIN_MTU, min_t(int, ENIC_MAX_MTU, new_mtu));
+ len = new_mtu + VLAN_ETH_HLEN + NET_IP_ALIGN + NET_SKB_PAD;
+ len = SKB_DATA_ALIGN(len) +
+ SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
rtnl_lock();
@@ -1927,6 +1940,11 @@ static void enic_change_mtu_work(struct work_struct *work)
/* Fill RQ with new_mtu-sized buffers */
netdev->mtu = new_mtu;
+ if (len > (PAGE_SIZE << enic->alloc_order)) {
+ enic->alloc_order = get_order(len);
+ netdev_warn(netdev, "new mtu is greater than size of rx alloc_page, resetting enic->alloc_order to :%d\n",
+ enic->alloc_order);
+ }
vnic_rq_fill(&enic->rq[0], enic_rq_alloc_buf);
/* Need at least one buffer on ring to get going */
if (vnic_rq_desc_used(&enic->rq[0]) == 0) {
--
2.2.2
next prev parent reply other threads:[~2015-01-31 12:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-31 12:28 [PATCH net-next 0/4] enic: improve rq buff allocation and reduce dma mapping Govindarajulu Varadarajan
2015-01-31 12:28 ` [PATCH net-next 1/4] enic: implement frag allocator Govindarajulu Varadarajan
2015-01-31 12:28 ` [PATCH net-next 2/4] enic: Add rq allocation failure stats Govindarajulu Varadarajan
2015-01-31 12:28 ` [PATCH net-next 3/4] ethtool: add RX_ALLOC_ORDER to tunable Govindarajulu Varadarajan
2015-02-03 3:21 ` David Miller
2015-02-03 9:49 ` Govindarajulu Varadarajan
2015-02-05 17:28 ` Govindarajulu Varadarajan
2015-01-31 12:28 ` Govindarajulu Varadarajan [this message]
2015-02-02 15:56 ` [PATCH net-next 0/4] enic: improve rq buff allocation and reduce dma mapping David Laight
2015-02-02 17:49 ` Govindarajulu Varadarajan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1422707290-939-5-git-send-email-_govind@gmx.com \
--to=_govind@gmx.com \
--cc=ben@decadent.org.uk \
--cc=benve@cisco.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=netdev@vger.kernel.org \
--cc=ssujith@cisco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).