1*1ef8019bSDavid S. Miller /* 2*1ef8019bSDavid S. Miller * drivers/net/bond/bond_options.h - bonding options 3*1ef8019bSDavid S. Miller * Copyright (c) 2013 Nikolay Aleksandrov <nikolay@redhat.com> 4*1ef8019bSDavid S. Miller * 5*1ef8019bSDavid S. Miller * This program is free software; you can redistribute it and/or modify 6*1ef8019bSDavid S. Miller * it under the terms of the GNU General Public License as published by 7*1ef8019bSDavid S. Miller * the Free Software Foundation; either version 2 of the License, or 8*1ef8019bSDavid S. Miller * (at your option) any later version. 9*1ef8019bSDavid S. Miller */ 10*1ef8019bSDavid S. Miller 11*1ef8019bSDavid S. Miller #ifndef _NET_BOND_OPTIONS_H 12*1ef8019bSDavid S. Miller #define _NET_BOND_OPTIONS_H 13*1ef8019bSDavid S. Miller 14*1ef8019bSDavid S. Miller #define BOND_OPT_MAX_NAMELEN 32 15*1ef8019bSDavid S. Miller #define BOND_OPT_VALID(opt) ((opt) < BOND_OPT_LAST) 16*1ef8019bSDavid S. Miller #define BOND_MODE_ALL_EX(x) (~(x)) 17*1ef8019bSDavid S. Miller 18*1ef8019bSDavid S. Miller /* Option flags: 19*1ef8019bSDavid S. Miller * BOND_OPTFLAG_NOSLAVES - check if the bond device is empty before setting 20*1ef8019bSDavid S. Miller * BOND_OPTFLAG_IFDOWN - check if the bond device is down before setting 21*1ef8019bSDavid S. Miller * BOND_OPTFLAG_RAWVAL - the option parses the value itself 22*1ef8019bSDavid S. Miller */ 23*1ef8019bSDavid S. Miller enum { 24*1ef8019bSDavid S. Miller BOND_OPTFLAG_NOSLAVES = BIT(0), 25*1ef8019bSDavid S. Miller BOND_OPTFLAG_IFDOWN = BIT(1), 26*1ef8019bSDavid S. Miller BOND_OPTFLAG_RAWVAL = BIT(2) 27*1ef8019bSDavid S. Miller }; 28*1ef8019bSDavid S. Miller 29*1ef8019bSDavid S. Miller /* Value type flags: 30*1ef8019bSDavid S. Miller * BOND_VALFLAG_DEFAULT - mark the value as default 31*1ef8019bSDavid S. Miller * BOND_VALFLAG_(MIN|MAX) - mark the value as min/max 32*1ef8019bSDavid S. Miller */ 33*1ef8019bSDavid S. Miller enum { 34*1ef8019bSDavid S. Miller BOND_VALFLAG_DEFAULT = BIT(0), 35*1ef8019bSDavid S. Miller BOND_VALFLAG_MIN = BIT(1), 36*1ef8019bSDavid S. Miller BOND_VALFLAG_MAX = BIT(2) 37*1ef8019bSDavid S. Miller }; 38*1ef8019bSDavid S. Miller 39*1ef8019bSDavid S. Miller /* Option IDs, their bit positions correspond to their IDs */ 40*1ef8019bSDavid S. Miller enum { 41*1ef8019bSDavid S. Miller BOND_OPT_MODE, 42*1ef8019bSDavid S. Miller BOND_OPT_PACKETS_PER_SLAVE, 43*1ef8019bSDavid S. Miller BOND_OPT_XMIT_HASH, 44*1ef8019bSDavid S. Miller BOND_OPT_ARP_VALIDATE, 45*1ef8019bSDavid S. Miller BOND_OPT_ARP_ALL_TARGETS, 46*1ef8019bSDavid S. Miller BOND_OPT_FAIL_OVER_MAC, 47*1ef8019bSDavid S. Miller BOND_OPT_ARP_INTERVAL, 48*1ef8019bSDavid S. Miller BOND_OPT_ARP_TARGETS, 49*1ef8019bSDavid S. Miller BOND_OPT_DOWNDELAY, 50*1ef8019bSDavid S. Miller BOND_OPT_UPDELAY, 51*1ef8019bSDavid S. Miller BOND_OPT_LACP_RATE, 52*1ef8019bSDavid S. Miller BOND_OPT_MINLINKS, 53*1ef8019bSDavid S. Miller BOND_OPT_AD_SELECT, 54*1ef8019bSDavid S. Miller BOND_OPT_NUM_PEER_NOTIF, 55*1ef8019bSDavid S. Miller BOND_OPT_MIIMON, 56*1ef8019bSDavid S. Miller BOND_OPT_PRIMARY, 57*1ef8019bSDavid S. Miller BOND_OPT_PRIMARY_RESELECT, 58*1ef8019bSDavid S. Miller BOND_OPT_USE_CARRIER, 59*1ef8019bSDavid S. Miller BOND_OPT_ACTIVE_SLAVE, 60*1ef8019bSDavid S. Miller BOND_OPT_QUEUE_ID, 61*1ef8019bSDavid S. Miller BOND_OPT_ALL_SLAVES_ACTIVE, 62*1ef8019bSDavid S. Miller BOND_OPT_RESEND_IGMP, 63*1ef8019bSDavid S. Miller BOND_OPT_LP_INTERVAL, 64*1ef8019bSDavid S. Miller BOND_OPT_SLAVES, 65*1ef8019bSDavid S. Miller BOND_OPT_TLB_DYNAMIC_LB, 66*1ef8019bSDavid S. Miller BOND_OPT_LAST 67*1ef8019bSDavid S. Miller }; 68*1ef8019bSDavid S. Miller 69*1ef8019bSDavid S. Miller /* This structure is used for storing option values and for passing option 70*1ef8019bSDavid S. Miller * values when changing an option. The logic when used as an arg is as follows: 71*1ef8019bSDavid S. Miller * - if string != NULL -> parse it, if the opt is RAW type then return it, else 72*1ef8019bSDavid S. Miller * return the parse result 73*1ef8019bSDavid S. Miller * - if string == NULL -> parse value 74*1ef8019bSDavid S. Miller */ 75*1ef8019bSDavid S. Miller struct bond_opt_value { 76*1ef8019bSDavid S. Miller char *string; 77*1ef8019bSDavid S. Miller u64 value; 78*1ef8019bSDavid S. Miller u32 flags; 79*1ef8019bSDavid S. Miller }; 80*1ef8019bSDavid S. Miller 81*1ef8019bSDavid S. Miller struct bonding; 82*1ef8019bSDavid S. Miller 83*1ef8019bSDavid S. Miller struct bond_option { 84*1ef8019bSDavid S. Miller int id; 85*1ef8019bSDavid S. Miller const char *name; 86*1ef8019bSDavid S. Miller const char *desc; 87*1ef8019bSDavid S. Miller u32 flags; 88*1ef8019bSDavid S. Miller 89*1ef8019bSDavid S. Miller /* unsuppmodes is used to denote modes in which the option isn't 90*1ef8019bSDavid S. Miller * supported. 91*1ef8019bSDavid S. Miller */ 92*1ef8019bSDavid S. Miller unsigned long unsuppmodes; 93*1ef8019bSDavid S. Miller /* supported values which this option can have, can be a subset of 94*1ef8019bSDavid S. Miller * BOND_OPTVAL_RANGE's value range 95*1ef8019bSDavid S. Miller */ 96*1ef8019bSDavid S. Miller const struct bond_opt_value *values; 97*1ef8019bSDavid S. Miller 98*1ef8019bSDavid S. Miller int (*set)(struct bonding *bond, const struct bond_opt_value *val); 99*1ef8019bSDavid S. Miller }; 100*1ef8019bSDavid S. Miller 101*1ef8019bSDavid S. Miller int __bond_opt_set(struct bonding *bond, unsigned int option, 102*1ef8019bSDavid S. Miller struct bond_opt_value *val); 103*1ef8019bSDavid S. Miller int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf); 104*1ef8019bSDavid S. Miller 105*1ef8019bSDavid S. Miller const struct bond_opt_value *bond_opt_parse(const struct bond_option *opt, 106*1ef8019bSDavid S. Miller struct bond_opt_value *val); 107*1ef8019bSDavid S. Miller const struct bond_option *bond_opt_get(unsigned int option); 108*1ef8019bSDavid S. Miller const struct bond_option *bond_opt_get_by_name(const char *name); 109*1ef8019bSDavid S. Miller const struct bond_opt_value *bond_opt_get_val(unsigned int option, u64 val); 110*1ef8019bSDavid S. Miller 111*1ef8019bSDavid S. Miller /* This helper is used to initialize a bond_opt_value structure for parameter 112*1ef8019bSDavid S. Miller * passing. There should be either a valid string or value, but not both. 113*1ef8019bSDavid S. Miller * When value is ULLONG_MAX then string will be used. 114*1ef8019bSDavid S. Miller */ 115*1ef8019bSDavid S. Miller static inline void __bond_opt_init(struct bond_opt_value *optval, 116*1ef8019bSDavid S. Miller char *string, u64 value) 117*1ef8019bSDavid S. Miller { 118*1ef8019bSDavid S. Miller memset(optval, 0, sizeof(*optval)); 119*1ef8019bSDavid S. Miller optval->value = ULLONG_MAX; 120*1ef8019bSDavid S. Miller if (value == ULLONG_MAX) 121*1ef8019bSDavid S. Miller optval->string = string; 122*1ef8019bSDavid S. Miller else 123*1ef8019bSDavid S. Miller optval->value = value; 124*1ef8019bSDavid S. Miller } 125*1ef8019bSDavid S. Miller #define bond_opt_initval(optval, value) __bond_opt_init(optval, NULL, value) 126*1ef8019bSDavid S. Miller #define bond_opt_initstr(optval, str) __bond_opt_init(optval, str, ULLONG_MAX) 127*1ef8019bSDavid S. Miller 128*1ef8019bSDavid S. Miller void bond_option_arp_ip_targets_clear(struct bonding *bond); 129*1ef8019bSDavid S. Miller 130*1ef8019bSDavid S. Miller #endif /* _NET_BOND_OPTIONS_H */ 131