Skip to content

Commit

Permalink
fjes: net_device_ops.ndo_change_mtu
Browse files Browse the repository at this point in the history
This patch adds net_device_ops.ndo_change_mtu.

Signed-off-by: Taku Izumi <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
izumi777 authored and davem330 committed Aug 24, 2015
1 parent 879bc9a commit b9e23a6
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions drivers/net/fjes/fjes_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ static void fjes_tx_stall_task(struct work_struct *);
static irqreturn_t fjes_intr(int, void*);
static struct rtnl_link_stats64 *
fjes_get_stats64(struct net_device *, struct rtnl_link_stats64 *);
static int fjes_change_mtu(struct net_device *, int);

static int fjes_acpi_add(struct acpi_device *);
static int fjes_acpi_remove(struct acpi_device *);
Expand Down Expand Up @@ -222,6 +223,7 @@ static const struct net_device_ops fjes_netdev_ops = {
.ndo_stop = fjes_close,
.ndo_start_xmit = fjes_xmit_frame,
.ndo_get_stats64 = fjes_get_stats64,
.ndo_change_mtu = fjes_change_mtu,
};

/* fjes_open - Called when a network interface is made active */
Expand Down Expand Up @@ -713,6 +715,33 @@ fjes_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
return stats;
}

static int fjes_change_mtu(struct net_device *netdev, int new_mtu)
{
bool running = netif_running(netdev);
int ret = 0;
int idx;

for (idx = 0; fjes_support_mtu[idx] != 0; idx++) {
if (new_mtu <= fjes_support_mtu[idx]) {
new_mtu = fjes_support_mtu[idx];
if (new_mtu == netdev->mtu)
return 0;

if (running)
fjes_close(netdev);

netdev->mtu = new_mtu;

if (running)
ret = fjes_open(netdev);

return ret;
}
}

return -EINVAL;
}

static irqreturn_t fjes_intr(int irq, void *data)
{
struct fjes_adapter *adapter = data;
Expand Down

0 comments on commit b9e23a6

Please sign in to comment.