From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from tyo201.gate.nec.co.jp (TYO201.gate.nec.co.jp [210.143.35.51]) by dpdk.org (Postfix) with ESMTP id 70C66B0AD for ; Wed, 18 Jun 2014 12:59:10 +0200 (CEST) Received: from mailgate3.nec.co.jp ([10.7.69.197]) by tyo201.gate.nec.co.jp (8.13.8/8.13.4) with ESMTP id s5IAxO3x002017 for ; Wed, 18 Jun 2014 19:59:24 +0900 (JST) Received: from mailsv3.nec.co.jp (imss63.nec.co.jp [10.7.69.158]) by mailgate3.nec.co.jp (8.11.7/3.7W-MAILGATE-NEC) with ESMTP id s5IAxOE10578 for ; Wed, 18 Jun 2014 19:59:24 +0900 (JST) Received: from mail03.kamome.nec.co.jp (mail03.kamome.nec.co.jp [10.25.43.7]) by mailsv3.nec.co.jp (8.13.8/8.13.4) with ESMTP id s5IAxOBp005073 for ; Wed, 18 Jun 2014 19:59:24 +0900 (JST) Received: from bpxc99gp.gisp.nec.co.jp ([10.38.151.142] [10.38.151.142]) by mail01b.kamome.nec.co.jp with ESMTP id BT-MMP-360646; Wed, 18 Jun 2014 19:57:16 +0900 Received: from BPXM14GP.gisp.nec.co.jp ([169.254.1.238]) by BPXC14GP.gisp.nec.co.jp ([10.38.151.142]) with mapi id 14.02.0328.011; Wed, 18 Jun 2014 19:57:16 +0900 From: Hiroshi Shimamoto To: "dev@dpdk.org" Thread-Topic: [memnic PATCH v2 5/5] linux: support MTU change Thread-Index: Ac+K492EvqNEs+JzS4OvnSwKq5h5Tg== Date: Wed, 18 Jun 2014 10:57:15 +0000 Message-ID: <7F861DC0615E0C47A872E6F3C5FCDDBD0111AFB0@BPXM14GP.gisp.nec.co.jp> Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.205.5.123] Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: Hayato Momma Subject: [dpdk-dev] [memnic PATCH v2 5/5] linux: support MTU change X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jun 2014 10:59:11 -0000 From: Hiroshi Shimamoto Add the capability to change MTU. On MTU change, remember the corresponding frame size and request new frame size to the host on reset, if the host MEMNIC has that feature. Don't trust framesz of header in general usage, because host might change the value unexpectedly. v2: forgot to update netdev->mtu on change, fix it. Signed-off-by: Hiroshi Shimamoto Reviewed-by: Hayato Momma --- linux/memnic_net.c | 41 ++++++++++++++++++++++++++++++++++++++--- linux/memnic_net.h | 5 +++++ 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/linux/memnic_net.c b/linux/memnic_net.c index 02b5acc..f92cbd1 100644 --- a/linux/memnic_net.c +++ b/linux/memnic_net.c @@ -31,6 +31,7 @@ =20 #include #include +#include =20 #include "memnic_net.h" #include "memnic.h" @@ -152,19 +153,31 @@ static int memnic_open(struct net_device *netdev) { struct memnic_net *memnic =3D netdev_priv(netdev); struct memnic_area *nic =3D memnic->dev->base_addr; + struct memnic_header *hdr =3D &nic->hdr; struct task_struct *kthread; =20 /* clear stats */ memset(&memnic->stats, 0, sizeof(memnic->stats)); /* invalidate and reset here */ - nic->hdr.valid =3D 0; + hdr->valid =3D 0; + + /* setup parameters */ + if (memnic->request.features & MEMNIC_FEAT_FRAME_SIZE) + hdr->framesz =3D memnic->request.framesz; + hdr->request =3D memnic->request.features; + smp_wmb(); - nic->hdr.reset =3D 1; + hdr->reset =3D 1; + + while (ACCESS_ONCE(hdr->reset)) + schedule_timeout_interruptible(HZ/100); + /* clear index */ memnic->up =3D 0; memnic->down =3D 0; memnic->framesz =3D MEMNIC_MAX_FRAME_LEN; - /* will become valid after reset handling in vswitch */ + if (memnic->request.features & MEMNIC_FEAT_FRAME_SIZE) + memnic->framesz =3D hdr->framesz; =20 /* already run */ if (memnic->kthread) @@ -260,6 +273,26 @@ static int memnic_set_mac(struct net_device *netdev, v= oid *p) =20 static int memnic_change_mtu(struct net_device *netdev, int new_mtu) { + struct memnic_net *memnic =3D netdev_priv(netdev); + struct memnic_area *nic =3D memnic->dev->base_addr; + struct memnic_header *hdr =3D &nic->hdr; + uint32_t framesz =3D new_mtu + ETH_HLEN + VLAN_HLEN; + + if (!(hdr->features & MEMNIC_FEAT_FRAME_SIZE)) + return -ENOSYS; + + /* new_mtu less than 68 might cause problem */ + if (new_mtu < 68 || framesz > MEMNIC_MAX_JUMBO_FRAME_LEN) + return -EINVAL; + + printk(KERN_INFO "MEMNIC: Changing MTU from %u to %u\n", + netdev->mtu, new_mtu); + + memnic->request.features |=3D MEMNIC_FEAT_FRAME_SIZE; + memnic->request.framesz =3D framesz; + + netdev->mtu =3D new_mtu; + return 0; } =20 @@ -298,6 +331,8 @@ struct memnic_net *memnic_net_create(struct memnic_dev = *dev) =20 memnic->netdev =3D netdev; memnic->dev =3D dev; + memnic->framesz =3D MEMNIC_MAX_FRAME_LEN; + memnic->request.features =3D 0; =20 netdev->netdev_ops =3D &memnic_netdev_ops; =20 diff --git a/linux/memnic_net.h b/linux/memnic_net.h index 10c8eed..b6c57ab 100644 --- a/linux/memnic_net.h +++ b/linux/memnic_net.h @@ -44,6 +44,11 @@ struct memnic_net { struct net_device_stats stats; int up, down; uint32_t framesz; + /* request to host */ + struct { + uint32_t features; + uint32_t framesz; + } request; }; =20 struct memnic_net *memnic_net_create(struct memnic_dev *dev); --=20 1.8.4