summaryrefslogtreecommitdiffstats
path: root/net/ncsi/internal.h
diff options
context:
space:
mode:
authorGavin Shan <gwshan@linux.vnet.ibm.com>2016-07-18 21:54:19 -0400
committerDavid S. Miller <davem@davemloft.net>2016-07-19 23:49:17 -0400
commite6f44ed6d04d3185dcd8e8e98af8742d87bdffcc (patch)
tree23f27bdac3262327102758adbded3886a209ba7b /net/ncsi/internal.h
parent138635cc27c9737f940c3aa80912ff7a61c825af (diff)
net/ncsi: Package and channel management
This manages NCSI packages and channels: * The available packages and channels are enumerated in the first time of calling ncsi_start_dev(). The channels' capabilities are probed in the meanwhile. The NCSI network topology won't change until the NCSI device is destroyed. * There in a queue in every NCSI device. The element in the queue, channel, is waiting for configuration (bringup) or suspending (teardown). The channel's state (inactive/active) indicates the futher action (configuration or suspending) will be applied on the channel. Another channel's state (invisible) means the requested action is being applied. * The hardware arbitration will be enabled if all available packages and channels support it. All available channels try to provide service when hardware arbitration is enabled. Otherwise, one channel is selected as the active one at once. * When channel is in active state, meaning it's providing service, a timer started to retrieve the channe's link status. If the channel's link status fails to be updated in the determined period, the channel is going to be reconfigured. It's the error handling implementation as defined in NCSI spec. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Acked-by: Joel Stanley <joel@jms.id.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ncsi/internal.h')
-rw-r--r--net/ncsi/internal.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h
index bd000c9c8249..38fc95a26f8f 100644
--- a/net/ncsi/internal.h
+++ b/net/ncsi/internal.h
@@ -178,6 +178,7 @@ struct ncsi_channel {
178 int state; 178 int state;
179#define NCSI_CHANNEL_INACTIVE 1 179#define NCSI_CHANNEL_INACTIVE 1
180#define NCSI_CHANNEL_ACTIVE 2 180#define NCSI_CHANNEL_ACTIVE 2
181#define NCSI_CHANNEL_INVISIBLE 3
181 spinlock_t lock; /* Protect filters etc */ 182 spinlock_t lock; /* Protect filters etc */
182 struct ncsi_package *package; 183 struct ncsi_package *package;
183 struct ncsi_channel_version version; 184 struct ncsi_channel_version version;
@@ -185,7 +186,11 @@ struct ncsi_channel {
185 struct ncsi_channel_mode modes[NCSI_MODE_MAX]; 186 struct ncsi_channel_mode modes[NCSI_MODE_MAX];
186 struct ncsi_channel_filter *filters[NCSI_FILTER_MAX]; 187 struct ncsi_channel_filter *filters[NCSI_FILTER_MAX];
187 struct ncsi_channel_stats stats; 188 struct ncsi_channel_stats stats;
189 struct timer_list timer; /* Link monitor timer */
190 bool enabled; /* Timer is enabled */
191 unsigned int timeout; /* Times of timeout */
188 struct list_head node; 192 struct list_head node;
193 struct list_head link;
189}; 194};
190 195
191struct ncsi_package { 196struct ncsi_package {
@@ -209,14 +214,56 @@ struct ncsi_request {
209 bool enabled; /* Time has been enabled or not */ 214 bool enabled; /* Time has been enabled or not */
210}; 215};
211 216
217enum {
218 ncsi_dev_state_major = 0xff00,
219 ncsi_dev_state_minor = 0x00ff,
220 ncsi_dev_state_probe_deselect = 0x0201,
221 ncsi_dev_state_probe_package,
222 ncsi_dev_state_probe_channel,
223 ncsi_dev_state_probe_cis,
224 ncsi_dev_state_probe_gvi,
225 ncsi_dev_state_probe_gc,
226 ncsi_dev_state_probe_gls,
227 ncsi_dev_state_probe_dp,
228 ncsi_dev_state_config_sp = 0x0301,
229 ncsi_dev_state_config_cis,
230 ncsi_dev_state_config_sma,
231 ncsi_dev_state_config_ebf,
232#if IS_ENABLED(CONFIG_IPV6)
233 ncsi_dev_state_config_egmf,
234#endif
235 ncsi_dev_state_config_ecnt,
236 ncsi_dev_state_config_ec,
237 ncsi_dev_state_config_ae,
238 ncsi_dev_state_config_gls,
239 ncsi_dev_state_config_done,
240 ncsi_dev_state_suspend_select = 0x0401,
241 ncsi_dev_state_suspend_dcnt,
242 ncsi_dev_state_suspend_dc,
243 ncsi_dev_state_suspend_deselect,
244 ncsi_dev_state_suspend_done
245};
246
212struct ncsi_dev_priv { 247struct ncsi_dev_priv {
213 struct ncsi_dev ndev; /* Associated NCSI device */ 248 struct ncsi_dev ndev; /* Associated NCSI device */
214 unsigned int flags; /* NCSI device flags */ 249 unsigned int flags; /* NCSI device flags */
250#define NCSI_DEV_PROBED 1 /* Finalized NCSI topology */
251#define NCSI_DEV_HWA 2 /* Enabled HW arbitration */
252#define NCSI_DEV_RESHUFFLE 4
215 spinlock_t lock; /* Protect the NCSI device */ 253 spinlock_t lock; /* Protect the NCSI device */
254#if IS_ENABLED(CONFIG_IPV6)
255 unsigned int inet6_addr_num; /* Number of IPv6 addresses */
256#endif
216 unsigned int package_num; /* Number of packages */ 257 unsigned int package_num; /* Number of packages */
217 struct list_head packages; /* List of packages */ 258 struct list_head packages; /* List of packages */
218 struct ncsi_request requests[256]; /* Request table */ 259 struct ncsi_request requests[256]; /* Request table */
219 unsigned int request_id; /* Last used request ID */ 260 unsigned int request_id; /* Last used request ID */
261 unsigned int pending_req_num; /* Number of pending requests */
262 struct ncsi_package *active_package; /* Currently handled package */
263 struct ncsi_channel *active_channel; /* Currently handled channel */
264 struct list_head channel_queue; /* Config queue of channels */
265 struct work_struct work; /* For channel management */
266 struct packet_type ptype; /* NCSI packet Rx handler */
220 struct list_head node; /* Form NCSI device list */ 267 struct list_head node; /* Form NCSI device list */
221}; 268};
222 269
@@ -251,6 +298,8 @@ extern spinlock_t ncsi_dev_lock;
251int ncsi_find_filter(struct ncsi_channel *nc, int table, void *data); 298int ncsi_find_filter(struct ncsi_channel *nc, int table, void *data);
252int ncsi_add_filter(struct ncsi_channel *nc, int table, void *data); 299int ncsi_add_filter(struct ncsi_channel *nc, int table, void *data);
253int ncsi_remove_filter(struct ncsi_channel *nc, int table, int index); 300int ncsi_remove_filter(struct ncsi_channel *nc, int table, int index);
301void ncsi_start_channel_monitor(struct ncsi_channel *nc);
302void ncsi_stop_channel_monitor(struct ncsi_channel *nc);
254struct ncsi_channel *ncsi_find_channel(struct ncsi_package *np, 303struct ncsi_channel *ncsi_find_channel(struct ncsi_package *np,
255 unsigned char id); 304 unsigned char id);
256struct ncsi_channel *ncsi_add_channel(struct ncsi_package *np, 305struct ncsi_channel *ncsi_add_channel(struct ncsi_package *np,
@@ -267,6 +316,7 @@ void ncsi_find_package_and_channel(struct ncsi_dev_priv *ndp,
267struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp, bool driven); 316struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp, bool driven);
268void ncsi_free_request(struct ncsi_request *nr); 317void ncsi_free_request(struct ncsi_request *nr);
269struct ncsi_dev *ncsi_find_dev(struct net_device *dev); 318struct ncsi_dev *ncsi_find_dev(struct net_device *dev);
319int ncsi_process_next_channel(struct ncsi_dev_priv *ndp);
270 320
271/* Packet handlers */ 321/* Packet handlers */
272u32 ncsi_calculate_checksum(unsigned char *data, int len); 322u32 ncsi_calculate_checksum(unsigned char *data, int len);