1 /* Broadcom NetXtreme-C/E network driver.
2  *
3  * Copyright (c) 2017 Broadcom Limited
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation.
8  */
9 
10 #ifndef BNXT_DEVLINK_H
11 #define BNXT_DEVLINK_H
12 
13 /* Struct to hold housekeeping info needed by devlink interface */
14 struct bnxt_dl {
15 	struct bnxt *bp;	/* back ptr to the controlling dev */
16 };
17 
18 static inline struct bnxt *bnxt_get_bp_from_dl(struct devlink *dl)
19 {
20 	return ((struct bnxt_dl *)devlink_priv(dl))->bp;
21 }
22 
23 /* To clear devlink pointer from bp, pass NULL dl */
24 static inline void bnxt_link_bp_to_dl(struct bnxt *bp, struct devlink *dl)
25 {
26 	bp->dl = dl;
27 
28 	/* add a back pointer in dl to bp */
29 	if (dl) {
30 		struct bnxt_dl *bp_dl = devlink_priv(dl);
31 
32 		bp_dl->bp = bp;
33 	}
34 }
35 
36 #define NVM_OFF_ENABLE_SRIOV		401
37 
38 enum bnxt_nvm_dir_type {
39 	BNXT_NVM_SHARED_CFG = 40,
40 	BNXT_NVM_PORT_CFG,
41 	BNXT_NVM_FUNC_CFG,
42 };
43 
44 struct bnxt_dl_nvm_param {
45 	u16 id;
46 	u16 offset;
47 	u16 dir_type;
48 	u16 num_bits;
49 };
50 
51 int bnxt_dl_register(struct bnxt *bp);
52 void bnxt_dl_unregister(struct bnxt *bp);
53 
54 #endif /* BNXT_DEVLINK_H */
55