611 lines · 16.6 KB · C
RawDownload
	if (err == -EOPNOTSUPP)		err = 0;	return err;}EXPORT_SYMBOL_GPL(switchdev_handle_port_obj_add); static int __switchdev_handle_port_obj_del(struct net_device *dev,			struct switchdev_notifier_port_obj_info *port_obj_info,			bool (*check_cb)(const struct net_device *dev),			int (*del_cb)(struct net_device *dev,				      const struct switchdev_obj *obj)){	struct net_device *lower_dev;	struct list_head *iter;	int err = -EOPNOTSUPP; 	if (check_cb(dev)) {		/* This flag is only checked if the return value is success. */		port_obj_info->handled = true;		return del_cb(dev, port_obj_info->obj);	} 	/* Switch ports might be stacked under e.g. a LAG. Ignore the	 * unsupported devices, another driver might be able to handle them. But	 * propagate to the callers any hard errors.	 *	 * If the driver does its own bookkeeping of stacked ports, it's not	 * necessary to go through this helper.	 */	netdev_for_each_lower_dev(dev, lower_dev, iter) {		if (netif_is_bridge_master(lower_dev))			continue; 		err = __switchdev_handle_port_obj_del(lower_dev, port_obj_info,						      check_cb, del_cb);		if (err && err != -EOPNOTSUPP)			return err;	} 	return err;} int switchdev_handle_port_obj_del(struct net_device *dev,			struct switchdev_notifier_port_obj_info *port_obj_info,			bool (*check_cb)(const struct net_device *dev),			int (*del_cb)(struct net_device *dev,				      const struct switchdev_obj *obj)){	int err; 	err = __switchdev_handle_port_obj_del(dev, port_obj_info, check_cb,					      del_cb);	if (err == -EOPNOTSUPP)		err = 0;	return err;}EXPORT_SYMBOL_GPL(switchdev_handle_port_obj_del); static int __switchdev_handle_port_attr_set(struct net_device *dev,			struct switchdev_notifier_port_attr_info *port_attr_info,			bool (*check_cb)(const struct net_device *dev),			int (*set_cb)(struct net_device *dev,				      const struct switchdev_attr *attr,				      struct switchdev_trans *trans)){	struct net_device *lower_dev;	struct list_head *iter;	int err = -EOPNOTSUPP; 	if (check_cb(dev)) {		port_attr_info->handled = true;		return set_cb(dev, port_attr_info->attr,			      port_attr_info->trans);	} 	/* Switch ports might be stacked under e.g. a LAG. Ignore the	 * unsupported devices, another driver might be able to handle them. But	 * propagate to the callers any hard errors.	 *	 * If the driver does its own bookkeeping of stacked ports, it's not	 * necessary to go through this helper.	 */	netdev_for_each_lower_dev(dev, lower_dev, iter) {		if (netif_is_bridge_master(lower_dev))			continue; 		err = __switchdev_handle_port_attr_set(lower_dev, port_attr_info,						       check_cb, set_cb);		if (err && err != -EOPNOTSUPP)			return err;	} 	return err;} int switchdev_handle_port_attr_set(struct net_device *dev,			struct switchdev_notifier_port_attr_info *port_attr_info,			bool (*check_cb)(const struct net_device *dev),			int (*set_cb)(struct net_device *dev,				      const struct switchdev_attr *attr,				      struct switchdev_trans *trans)){	int err; 	err = __switchdev_handle_port_attr_set(dev, port_attr_info, check_cb,					       set_cb);	if (err == -EOPNOTSUPP)		err = 0;	return err;}EXPORT_SYMBOL_GPL(switchdev_handle_port_attr_set);

Lines 501–611 of 611. Previous lines