Path: blob/master/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
15112 views
/*1* Copyright (c) 2007 Mellanox Technologies. All rights reserved.2*3* This software is available to you under a choice of one of two4* licenses. You may choose to be licensed under the terms of the GNU5* General Public License (GPL) Version 2, available from the file6* COPYING in the main directory of this source tree, or the7* OpenIB.org BSD license below:8*9* Redistribution and use in source and binary forms, with or10* without modification, are permitted provided that the following11* conditions are met:12*13* - Redistributions of source code must retain the above14* copyright notice, this list of conditions and the following15* disclaimer.16*17* - Redistributions in binary form must reproduce the above18* copyright notice, this list of conditions and the following19* disclaimer in the documentation and/or other materials20* provided with the distribution.21*22* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,23* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF24* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND25* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS26* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN27* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN28* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE29* SOFTWARE.30*/3132#include <linux/kernel.h>33#include <linux/ethtool.h>34#include <linux/netdevice.h>3536#include "ipoib.h"3738static void ipoib_get_drvinfo(struct net_device *netdev,39struct ethtool_drvinfo *drvinfo)40{41strncpy(drvinfo->driver, "ipoib", sizeof(drvinfo->driver) - 1);42}4344static int ipoib_get_coalesce(struct net_device *dev,45struct ethtool_coalesce *coal)46{47struct ipoib_dev_priv *priv = netdev_priv(dev);4849coal->rx_coalesce_usecs = priv->ethtool.coalesce_usecs;50coal->rx_max_coalesced_frames = priv->ethtool.max_coalesced_frames;5152return 0;53}5455static int ipoib_set_coalesce(struct net_device *dev,56struct ethtool_coalesce *coal)57{58struct ipoib_dev_priv *priv = netdev_priv(dev);59int ret;6061/*62* These values are saved in the private data and returned63* when ipoib_get_coalesce() is called64*/65if (coal->rx_coalesce_usecs > 0xffff ||66coal->rx_max_coalesced_frames > 0xffff)67return -EINVAL;6869ret = ib_modify_cq(priv->recv_cq, coal->rx_max_coalesced_frames,70coal->rx_coalesce_usecs);71if (ret && ret != -ENOSYS) {72ipoib_warn(priv, "failed modifying CQ (%d)\n", ret);73return ret;74}7576priv->ethtool.coalesce_usecs = coal->rx_coalesce_usecs;77priv->ethtool.max_coalesced_frames = coal->rx_max_coalesced_frames;7879return 0;80}8182static const struct ethtool_ops ipoib_ethtool_ops = {83.get_drvinfo = ipoib_get_drvinfo,84.get_coalesce = ipoib_get_coalesce,85.set_coalesce = ipoib_set_coalesce,86};8788void ipoib_set_ethtool_ops(struct net_device *dev)89{90SET_ETHTOOL_OPS(dev, &ipoib_ethtool_ops);91}929394