net/nfp: add NSP support for HW link configuration
[dpdk.git] / drivers / net / nfp / nfp_net_eth.h
1 /*
2  * Copyright (c) 2017 Netronome Systems, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  *  this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *  notice, this list of conditions and the following disclaimer in the
13  *  documentation and/or other materials provided with the distribution
14  *
15  * 3. Neither the name of the copyright holder nor the names of its
16  *  contributors may be used to endorse or promote products derived from this
17  *  software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31
32 /*
33  * vim:shiftwidth=8:noexpandtab
34  *
35  * @file dpdk/pmd/nfp_net_eth.h
36  *
37  * Netronome NFP_NET PDM driver
38  */
39
40 union eth_table_entry {
41         struct {
42                 uint64_t port;
43                 uint64_t state;
44                 uint8_t mac_addr[6];
45                 uint8_t resv[2];
46                 uint64_t control;
47         };
48         uint64_t raw[4];
49 };
50
51 #ifndef BIT_ULL
52 #define BIT_ULL(a) (1ULL << (a))
53 #endif
54
55 #define NSP_ETH_NBI_PORT_COUNT          24
56 #define NSP_ETH_MAX_COUNT               (2 * NSP_ETH_NBI_PORT_COUNT)
57 #define NSP_ETH_TABLE_SIZE   (NSP_ETH_MAX_COUNT * sizeof(union eth_table_entry))
58
59 #define NSP_ETH_PORT_LANES              0xf
60 #define NSP_ETH_PORT_INDEX              0xff00
61 #define NSP_ETH_PORT_LABEL              0x3f000000000000
62 #define NSP_ETH_PORT_PHYLABEL           0xfc0000000000000
63
64 #define NSP_ETH_PORT_LANES_MASK         rte_cpu_to_le_64(NSP_ETH_PORT_LANES)
65
66 #define NSP_ETH_STATE_CONFIGURED        BIT_ULL(0)
67 #define NSP_ETH_STATE_ENABLED           BIT_ULL(1)
68 #define NSP_ETH_STATE_TX_ENABLED        BIT_ULL(2)
69 #define NSP_ETH_STATE_RX_ENABLED        BIT_ULL(3)
70 #define NSP_ETH_STATE_RATE              0xf00
71 #define NSP_ETH_STATE_INTERFACE         0xff000
72 #define NSP_ETH_STATE_MEDIA             0x300000
73 #define NSP_ETH_STATE_OVRD_CHNG         BIT_ULL(22)
74 #define NSP_ETH_STATE_ANEG              0x3800000
75
76 #define NSP_ETH_CTRL_CONFIGURED         BIT_ULL(0)
77 #define NSP_ETH_CTRL_ENABLED            BIT_ULL(1)
78 #define NSP_ETH_CTRL_TX_ENABLED         BIT_ULL(2)
79 #define NSP_ETH_CTRL_RX_ENABLED         BIT_ULL(3)
80 #define NSP_ETH_CTRL_SET_RATE           BIT_ULL(4)
81 #define NSP_ETH_CTRL_SET_LANES          BIT_ULL(5)
82 #define NSP_ETH_CTRL_SET_ANEG           BIT_ULL(6)