/* * MDEV driver * * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. * Author: Neo Jia * Kirti Wankhede * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include #include #include #include "mdev_private.h" static int mdev_attach_iommu(struct mdev_device *mdev) { int ret; struct iommu_group *group; group = iommu_group_alloc(); if (IS_ERR(group)) return PTR_ERR(group); ret = iommu_group_add_device(group, &mdev->dev); if (!ret) dev_info(&mdev->dev, "MDEV: group_id = %d\n", iommu_group_id(group)); iommu_group_put(group); return ret; } static void mdev_detach_iommu(struct mdev_device *mdev) { iommu_group_remove_device(&mdev->dev); dev_info(&mdev->dev, "MDEV: detaching iommu\n"); } static int mdev_probe(struct device *dev) { struct mdev_driver *drv = to_mdev_driver(dev->driver); struct mdev_device *mdev = to_mdev_device(dev); int ret; ret = mdev_attach_iommu(mdev); if (ret) return ret; if (drv && drv->probe) { ret = drv->probe(dev); if (ret) mdev_detach_iommu(mdev); } return ret; } static int mdev_remove(struct device *dev) { struct mdev_driver *drv = to_mdev_driver(dev->driver); struct mdev_device *mdev = to_mdev_device(dev); if (drv && drv->remove) drv->remove(dev); mdev_detach_iommu(mdev); return 0; } struct bus_type mdev_bus_type = { .name = "mdev", .probe = mdev_probe, .remove = mdev_remove, }; EXPORT_SYMBOL_GPL(mdev_bus_type); /** * mdev_register_driver - register a new MDEV driver * @drv: the driver to register * @owner: module owner of driver to be registered * * Returns a negative value on error, otherwise 0. **/ int mdev_register_driver(struct mdev_driver *drv, struct module *owner) { /* initialize common driver fields */ drv->driver.name = drv->name; drv->driver.bus = &mdev_bus_type; drv->driver.owner = owner; /* register with core */ return driver_register(&drv->driver); } EXPORT_SYMBOL(mdev_register_driver); /* * mdev_unregister_driver - unregister MDEV driver * @drv: the driver to unregister */ void mdev_unregister_driver(struct mdev_driver *drv) { driver_unregister(&drv->driver); } EXPORT_SYMBOL(mdev_unregister_driver); int mdev_bus_register(void) { return bus_register(&mdev_bus_type); } void mdev_bus_unregister(void) { bus_unregister(&mdev_bus_type); } t'>
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2017-01-30 15:55:48 -0500
committerDavid S. Miller <davem@davemloft.net>2017-01-30 15:56:40 -0500
commit1930b60352e7e195f55b27cde15d2a8f43342a8b (patch)
treeec3f66cd8d8110bf7b4f61e0446bdea505915db9 /net/ceph/crush/hash.c
parent4be9993493bc7ee3fdf950a83bc050a3e6cf2a45 (diff)
parentec960de61503ef349588dccfa3ae02efabcc2762 (diff)
Merge branch 'dsa-port-mirroring'
Florian Fainelli says: ==================== net: dsa: Port mirroring support This patch series adds support for port mirroring in the two Broadcom switch drivers. The major part of the functional are actually with the plumbing between tc and the drivers. Changes in v5: - Added Jiri's Reviewed-by tag to first patch - rebase against latest net-next/master after bcm_sf2 CFP series Changes in v4: - rebased against latest net-next/master after Vivien's changes Changes in v3: - removed multiline comments from added structures - simplify error handling in dsa_slave_add_cls_matchall Changes in v2: - fixed filter removal logic to disable the ingress or egress mirroring when there are no longer ports being monitored in ingress or egress - removed a stray list_head in dsa_port structure that is not used Tested using the two iproute2 examples: tc qdisc add dev eth1 handle ffff: ingress tc filter add dev eth1 parent ffff: \ matchall skip_sw \ action mirred egress mirror \ dev eth2 tc qdisc add dev eth1 handle 1: root prio tc filter add dev eth1 parent 1: \ matchall skip_sw \ action mirred egress mirror \ dev eth2 ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ceph/crush/hash.c')