12874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 21ef8019bSDavid S. Miller /* 31ef8019bSDavid S. Miller * drivers/net/bond/bond_options.h - bonding options 41ef8019bSDavid S. Miller * Copyright (c) 2013 Nikolay Aleksandrov <nikolay@redhat.com> 51ef8019bSDavid S. Miller */ 61ef8019bSDavid S. Miller 71ef8019bSDavid S. Miller #ifndef _NET_BOND_OPTIONS_H 81ef8019bSDavid S. Miller #define _NET_BOND_OPTIONS_H 91ef8019bSDavid S. Miller 101ef8019bSDavid S. Miller #define BOND_OPT_MAX_NAMELEN 32 111ef8019bSDavid S. Miller #define BOND_OPT_VALID(opt) ((opt) < BOND_OPT_LAST) 121ef8019bSDavid S. Miller #define BOND_MODE_ALL_EX(x) (~(x)) 131ef8019bSDavid S. Miller 141ef8019bSDavid S. Miller /* Option flags: 151ef8019bSDavid S. Miller * BOND_OPTFLAG_NOSLAVES - check if the bond device is empty before setting 161ef8019bSDavid S. Miller * BOND_OPTFLAG_IFDOWN - check if the bond device is down before setting 171ef8019bSDavid S. Miller * BOND_OPTFLAG_RAWVAL - the option parses the value itself 181ef8019bSDavid S. Miller */ 191ef8019bSDavid S. Miller enum { 201ef8019bSDavid S. Miller BOND_OPTFLAG_NOSLAVES = BIT(0), 211ef8019bSDavid S. Miller BOND_OPTFLAG_IFDOWN = BIT(1), 221ef8019bSDavid S. Miller BOND_OPTFLAG_RAWVAL = BIT(2) 231ef8019bSDavid S. Miller }; 241ef8019bSDavid S. Miller 251ef8019bSDavid S. Miller /* Value type flags: 261ef8019bSDavid S. Miller * BOND_VALFLAG_DEFAULT - mark the value as default 271ef8019bSDavid S. Miller * BOND_VALFLAG_(MIN|MAX) - mark the value as min/max 281ef8019bSDavid S. Miller */ 291ef8019bSDavid S. Miller enum { 301ef8019bSDavid S. Miller BOND_VALFLAG_DEFAULT = BIT(0), 311ef8019bSDavid S. Miller BOND_VALFLAG_MIN = BIT(1), 321ef8019bSDavid S. Miller BOND_VALFLAG_MAX = BIT(2) 331ef8019bSDavid S. Miller }; 341ef8019bSDavid S. Miller 351ef8019bSDavid S. Miller /* Option IDs, their bit positions correspond to their IDs */ 361ef8019bSDavid S. Miller enum { 371ef8019bSDavid S. Miller BOND_OPT_MODE, 381ef8019bSDavid S. Miller BOND_OPT_PACKETS_PER_SLAVE, 391ef8019bSDavid S. Miller BOND_OPT_XMIT_HASH, 401ef8019bSDavid S. Miller BOND_OPT_ARP_VALIDATE, 411ef8019bSDavid S. Miller BOND_OPT_ARP_ALL_TARGETS, 421ef8019bSDavid S. Miller BOND_OPT_FAIL_OVER_MAC, 431ef8019bSDavid S. Miller BOND_OPT_ARP_INTERVAL, 441ef8019bSDavid S. Miller BOND_OPT_ARP_TARGETS, 451ef8019bSDavid S. Miller BOND_OPT_DOWNDELAY, 461ef8019bSDavid S. Miller BOND_OPT_UPDELAY, 471ef8019bSDavid S. Miller BOND_OPT_LACP_RATE, 481ef8019bSDavid S. Miller BOND_OPT_MINLINKS, 491ef8019bSDavid S. Miller BOND_OPT_AD_SELECT, 501ef8019bSDavid S. Miller BOND_OPT_NUM_PEER_NOTIF, 511ef8019bSDavid S. Miller BOND_OPT_MIIMON, 521ef8019bSDavid S. Miller BOND_OPT_PRIMARY, 531ef8019bSDavid S. Miller BOND_OPT_PRIMARY_RESELECT, 541ef8019bSDavid S. Miller BOND_OPT_USE_CARRIER, 551ef8019bSDavid S. Miller BOND_OPT_ACTIVE_SLAVE, 561ef8019bSDavid S. Miller BOND_OPT_QUEUE_ID, 571ef8019bSDavid S. Miller BOND_OPT_ALL_SLAVES_ACTIVE, 581ef8019bSDavid S. Miller BOND_OPT_RESEND_IGMP, 591ef8019bSDavid S. Miller BOND_OPT_LP_INTERVAL, 601ef8019bSDavid S. Miller BOND_OPT_SLAVES, 611ef8019bSDavid S. Miller BOND_OPT_TLB_DYNAMIC_LB, 626791e466SMahesh Bandewar BOND_OPT_AD_ACTOR_SYS_PRIO, 6374514957SMahesh Bandewar BOND_OPT_AD_ACTOR_SYSTEM, 64d22a5fc0SMahesh Bandewar BOND_OPT_AD_USER_PORT_KEY, 65205845a3SNikolay Aleksandrov BOND_OPT_NUM_PEER_NOTIF_ALIAS, 6607a4ddecSVincent Bernat BOND_OPT_PEER_NOTIF_DELAY, 67*3a755cd8SHangbin Liu BOND_OPT_LACP_ACTIVE, 681ef8019bSDavid S. Miller BOND_OPT_LAST 691ef8019bSDavid S. Miller }; 701ef8019bSDavid S. Miller 711ef8019bSDavid S. Miller /* This structure is used for storing option values and for passing option 721ef8019bSDavid S. Miller * values when changing an option. The logic when used as an arg is as follows: 731ef8019bSDavid S. Miller * - if string != NULL -> parse it, if the opt is RAW type then return it, else 741ef8019bSDavid S. Miller * return the parse result 751ef8019bSDavid S. Miller * - if string == NULL -> parse value 761ef8019bSDavid S. Miller */ 771ef8019bSDavid S. Miller struct bond_opt_value { 781ef8019bSDavid S. Miller char *string; 791ef8019bSDavid S. Miller u64 value; 801ef8019bSDavid S. Miller u32 flags; 811ef8019bSDavid S. Miller }; 821ef8019bSDavid S. Miller 831ef8019bSDavid S. Miller struct bonding; 841ef8019bSDavid S. Miller 851ef8019bSDavid S. Miller struct bond_option { 861ef8019bSDavid S. Miller int id; 871ef8019bSDavid S. Miller const char *name; 881ef8019bSDavid S. Miller const char *desc; 891ef8019bSDavid S. Miller u32 flags; 901ef8019bSDavid S. Miller 911ef8019bSDavid S. Miller /* unsuppmodes is used to denote modes in which the option isn't 921ef8019bSDavid S. Miller * supported. 931ef8019bSDavid S. Miller */ 941ef8019bSDavid S. Miller unsigned long unsuppmodes; 951ef8019bSDavid S. Miller /* supported values which this option can have, can be a subset of 961ef8019bSDavid S. Miller * BOND_OPTVAL_RANGE's value range 971ef8019bSDavid S. Miller */ 981ef8019bSDavid S. Miller const struct bond_opt_value *values; 991ef8019bSDavid S. Miller 1001ef8019bSDavid S. Miller int (*set)(struct bonding *bond, const struct bond_opt_value *val); 1011ef8019bSDavid S. Miller }; 1021ef8019bSDavid S. Miller 1031ef8019bSDavid S. Miller int __bond_opt_set(struct bonding *bond, unsigned int option, 1041ef8019bSDavid S. Miller struct bond_opt_value *val); 1057a7e96e0SVlad Yasevich int __bond_opt_set_notify(struct bonding *bond, unsigned int option, 1067a7e96e0SVlad Yasevich struct bond_opt_value *val); 1071ef8019bSDavid S. Miller int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf); 1081ef8019bSDavid S. Miller 1091ef8019bSDavid S. Miller const struct bond_opt_value *bond_opt_parse(const struct bond_option *opt, 1101ef8019bSDavid S. Miller struct bond_opt_value *val); 1111ef8019bSDavid S. Miller const struct bond_option *bond_opt_get(unsigned int option); 1121ef8019bSDavid S. Miller const struct bond_option *bond_opt_get_by_name(const char *name); 1131ef8019bSDavid S. Miller const struct bond_opt_value *bond_opt_get_val(unsigned int option, u64 val); 1141ef8019bSDavid S. Miller 1151ef8019bSDavid S. Miller /* This helper is used to initialize a bond_opt_value structure for parameter 1161ef8019bSDavid S. Miller * passing. There should be either a valid string or value, but not both. 1171ef8019bSDavid S. Miller * When value is ULLONG_MAX then string will be used. 1181ef8019bSDavid S. Miller */ 1191ef8019bSDavid S. Miller static inline void __bond_opt_init(struct bond_opt_value *optval, 1201ef8019bSDavid S. Miller char *string, u64 value) 1211ef8019bSDavid S. Miller { 1221ef8019bSDavid S. Miller memset(optval, 0, sizeof(*optval)); 1231ef8019bSDavid S. Miller optval->value = ULLONG_MAX; 1241ef8019bSDavid S. Miller if (value == ULLONG_MAX) 1251ef8019bSDavid S. Miller optval->string = string; 1261ef8019bSDavid S. Miller else 1271ef8019bSDavid S. Miller optval->value = value; 1281ef8019bSDavid S. Miller } 1291ef8019bSDavid S. Miller #define bond_opt_initval(optval, value) __bond_opt_init(optval, NULL, value) 1301ef8019bSDavid S. Miller #define bond_opt_initstr(optval, str) __bond_opt_init(optval, str, ULLONG_MAX) 1311ef8019bSDavid S. Miller 1321ef8019bSDavid S. Miller void bond_option_arp_ip_targets_clear(struct bonding *bond); 1331ef8019bSDavid S. Miller 1341ef8019bSDavid S. Miller #endif /* _NET_BOND_OPTIONS_H */ 135