| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
|---|
| 1 | 2 | /**************************************************************************/ |
|---|
| 2 | 3 | /* */ |
|---|
| 3 | 4 | /* IBM System i and System p Virtual NIC Device Driver */ |
|---|
| .. | .. |
|---|
| 6 | 7 | /* Thomas Falcon (tlfalcon@linux.vnet.ibm.com) */ |
|---|
| 7 | 8 | /* John Allen (jallen@linux.vnet.ibm.com) */ |
|---|
| 8 | 9 | /* */ |
|---|
| 9 | | -/* This program is free software; you can redistribute it and/or modify */ |
|---|
| 10 | | -/* it under the terms of the GNU General Public License as published by */ |
|---|
| 11 | | -/* the Free Software Foundation; either version 2 of the License, or */ |
|---|
| 12 | | -/* (at your option) any later version. */ |
|---|
| 13 | | -/* */ |
|---|
| 14 | | -/* This program is distributed in the hope that it will be useful, */ |
|---|
| 15 | | -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ |
|---|
| 16 | | -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ |
|---|
| 17 | | -/* GNU General Public License for more details. */ |
|---|
| 18 | | -/* */ |
|---|
| 19 | | -/* You should have received a copy of the GNU General Public License */ |
|---|
| 20 | | -/* along with this program. */ |
|---|
| 21 | 10 | /* */ |
|---|
| 22 | 11 | /* This module contains the implementation of a virtual ethernet device */ |
|---|
| 23 | 12 | /* for use with IBM i/pSeries LPAR Linux. It utilizes the logical LAN */ |
|---|
| .. | .. |
|---|
| 31 | 20 | #define IBMVNIC_INVALID_MAP -1 |
|---|
| 32 | 21 | #define IBMVNIC_STATS_TIMEOUT 1 |
|---|
| 33 | 22 | #define IBMVNIC_INIT_FAILED 2 |
|---|
| 23 | +#define IBMVNIC_OPEN_FAILED 3 |
|---|
| 34 | 24 | |
|---|
| 35 | 25 | /* basic structures plus 100 2k buffers */ |
|---|
| 36 | 26 | #define IBMVNIC_IO_ENTITLEMENT_DEFAULT 610305 |
|---|
| .. | .. |
|---|
| 39 | 29 | #define IBMVNIC_RX_WEIGHT 16 |
|---|
| 40 | 30 | /* when changing this, update IBMVNIC_IO_ENTITLEMENT_DEFAULT */ |
|---|
| 41 | 31 | #define IBMVNIC_BUFFS_PER_POOL 100 |
|---|
| 42 | | -#define IBMVNIC_MAX_QUEUES 10 |
|---|
| 32 | +#define IBMVNIC_MAX_QUEUES 16 |
|---|
| 33 | +#define IBMVNIC_MAX_QUEUE_SZ 4096 |
|---|
| 43 | 34 | |
|---|
| 44 | 35 | #define IBMVNIC_TSO_BUF_SZ 65536 |
|---|
| 45 | 36 | #define IBMVNIC_TSO_BUFS 64 |
|---|
| .. | .. |
|---|
| 47 | 38 | |
|---|
| 48 | 39 | #define IBMVNIC_MAX_LTB_SIZE ((1 << (MAX_ORDER - 1)) * PAGE_SIZE) |
|---|
| 49 | 40 | #define IBMVNIC_BUFFER_HLEN 500 |
|---|
| 41 | + |
|---|
| 42 | +#define IBMVNIC_RESET_DELAY 100 |
|---|
| 50 | 43 | |
|---|
| 51 | 44 | struct ibmvnic_login_buffer { |
|---|
| 52 | 45 | __be32 len; |
|---|
| .. | .. |
|---|
| 371 | 364 | u8 flags2; |
|---|
| 372 | 365 | #define IBMVNIC_LOGICAL_LNK_ACTIVE 0x80 |
|---|
| 373 | 366 | __be32 speed; |
|---|
| 374 | | -#define IBMVNIC_AUTONEG 0x80 |
|---|
| 375 | | -#define IBMVNIC_10MBPS 0x40 |
|---|
| 376 | | -#define IBMVNIC_100MBPS 0x20 |
|---|
| 377 | | -#define IBMVNIC_1GBPS 0x10 |
|---|
| 378 | | -#define IBMVNIC_10GBPS 0x08 |
|---|
| 367 | +#define IBMVNIC_AUTONEG 0x80000000 |
|---|
| 368 | +#define IBMVNIC_10MBPS 0x40000000 |
|---|
| 369 | +#define IBMVNIC_100MBPS 0x20000000 |
|---|
| 370 | +#define IBMVNIC_1GBPS 0x10000000 |
|---|
| 371 | +#define IBMVNIC_10GBPS 0x08000000 |
|---|
| 372 | +#define IBMVNIC_40GBPS 0x04000000 |
|---|
| 373 | +#define IBMVNIC_100GBPS 0x02000000 |
|---|
| 374 | +#define IBMVNIC_25GBPS 0x01000000 |
|---|
| 375 | +#define IBMVNIC_50GBPS 0x00800000 |
|---|
| 376 | +#define IBMVNIC_200GBPS 0x00400000 |
|---|
| 379 | 377 | __be32 mtu; |
|---|
| 380 | 378 | struct ibmvnic_rc rc; |
|---|
| 381 | 379 | } __packed __aligned(8); |
|---|
| .. | .. |
|---|
| 844 | 842 | dma_addr_t msg_token; |
|---|
| 845 | 843 | spinlock_t lock; |
|---|
| 846 | 844 | bool active; |
|---|
| 845 | + char name[32]; |
|---|
| 847 | 846 | }; |
|---|
| 848 | 847 | |
|---|
| 849 | 848 | union sub_crq { |
|---|
| .. | .. |
|---|
| 870 | 869 | struct sk_buff *rx_skb_top; |
|---|
| 871 | 870 | struct ibmvnic_adapter *adapter; |
|---|
| 872 | 871 | atomic_t used; |
|---|
| 872 | + char name[32]; |
|---|
| 873 | + u64 handle; |
|---|
| 873 | 874 | }; |
|---|
| 874 | 875 | |
|---|
| 875 | 876 | struct ibmvnic_long_term_buff { |
|---|
| .. | .. |
|---|
| 956 | 957 | u64 rx_entries; |
|---|
| 957 | 958 | u64 tx_entries; |
|---|
| 958 | 959 | u64 mtu; |
|---|
| 959 | | - struct sockaddr mac; |
|---|
| 960 | 960 | }; |
|---|
| 961 | 961 | |
|---|
| 962 | 962 | struct ibmvnic_adapter { |
|---|
| .. | .. |
|---|
| 992 | 992 | int phys_link_state; |
|---|
| 993 | 993 | int logical_link_state; |
|---|
| 994 | 994 | |
|---|
| 995 | + u32 speed; |
|---|
| 996 | + u8 duplex; |
|---|
| 997 | + |
|---|
| 995 | 998 | /* login data */ |
|---|
| 996 | 999 | struct ibmvnic_login_buffer *login_buf; |
|---|
| 997 | 1000 | dma_addr_t login_buf_token; |
|---|
| .. | .. |
|---|
| 1018 | 1021 | int init_done_rc; |
|---|
| 1019 | 1022 | |
|---|
| 1020 | 1023 | struct completion fw_done; |
|---|
| 1024 | + /* Used for serialization of device commands */ |
|---|
| 1025 | + struct mutex fw_lock; |
|---|
| 1021 | 1026 | int fw_done_rc; |
|---|
| 1022 | 1027 | |
|---|
| 1023 | 1028 | struct completion reset_done; |
|---|
| .. | .. |
|---|
| 1064 | 1069 | u32 num_active_rx_napi; |
|---|
| 1065 | 1070 | u32 num_active_tx_scrqs; |
|---|
| 1066 | 1071 | u32 num_active_tx_pools; |
|---|
| 1072 | + u32 cur_rx_buf_sz; |
|---|
| 1067 | 1073 | |
|---|
| 1068 | 1074 | struct tasklet_struct tasklet; |
|---|
| 1069 | 1075 | enum vnic_state state; |
|---|
| 1070 | 1076 | enum ibmvnic_reset_reason reset_reason; |
|---|
| 1077 | + /* when taking both state and rwi locks, take state lock first */ |
|---|
| 1071 | 1078 | spinlock_t rwi_lock; |
|---|
| 1072 | 1079 | struct list_head rwi_list; |
|---|
| 1073 | 1080 | struct work_struct ibmvnic_reset; |
|---|
| 1074 | | - bool resetting; |
|---|
| 1081 | + struct delayed_work ibmvnic_delayed_reset; |
|---|
| 1082 | + unsigned long resetting; |
|---|
| 1075 | 1083 | bool napi_enabled, from_passive_init; |
|---|
| 1084 | + bool login_pending; |
|---|
| 1085 | + /* last device reset time */ |
|---|
| 1086 | + unsigned long last_reset_time; |
|---|
| 1076 | 1087 | |
|---|
| 1077 | | - bool mac_change_pending; |
|---|
| 1078 | 1088 | bool failover_pending; |
|---|
| 1079 | 1089 | bool force_reset_recovery; |
|---|
| 1080 | 1090 | |
|---|
| 1081 | 1091 | struct ibmvnic_tunables desired; |
|---|
| 1082 | 1092 | struct ibmvnic_tunables fallback; |
|---|
| 1093 | + |
|---|
| 1094 | + /* Used for serialization of state field. When taking both state |
|---|
| 1095 | + * and rwi locks, take state lock first. |
|---|
| 1096 | + */ |
|---|
| 1097 | + spinlock_t state_lock; |
|---|
| 1083 | 1098 | }; |
|---|