Sathya Perla | 4ab0c6a | 2017-07-24 12:34:27 -0400 | [diff] [blame] | 1 | /* Broadcom NetXtreme-C/E network driver. |
| 2 | * |
| 3 | * Copyright (c) 2016-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_VFR_H |
| 11 | #define BNXT_VFR_H |
| 12 | |
Sathya Perla | d3e3bec | 2017-07-25 13:28:39 -0400 | [diff] [blame] | 13 | #ifdef CONFIG_BNXT_SRIOV |
| 14 | |
Sathya Perla | 4ab0c6a | 2017-07-24 12:34:27 -0400 | [diff] [blame] | 15 | #define MAX_CFA_CODE 65536 |
| 16 | |
| 17 | /* Struct to hold housekeeping info needed by devlink interface */ |
| 18 | struct bnxt_dl { |
| 19 | struct bnxt *bp; /* back ptr to the controlling dev */ |
| 20 | }; |
| 21 | |
| 22 | static inline struct bnxt *bnxt_get_bp_from_dl(struct devlink *dl) |
| 23 | { |
| 24 | return ((struct bnxt_dl *)devlink_priv(dl))->bp; |
| 25 | } |
| 26 | |
Sathya Perla | 7085560 | 2017-08-28 13:40:32 -0400 | [diff] [blame] | 27 | /* To clear devlink pointer from bp, pass NULL dl */ |
| 28 | static inline void bnxt_link_bp_to_dl(struct bnxt *bp, struct devlink *dl) |
Sathya Perla | 4ab0c6a | 2017-07-24 12:34:27 -0400 | [diff] [blame] | 29 | { |
Sathya Perla | 7085560 | 2017-08-28 13:40:32 -0400 | [diff] [blame] | 30 | bp->dl = dl; |
Sathya Perla | 4ab0c6a | 2017-07-24 12:34:27 -0400 | [diff] [blame] | 31 | |
Sathya Perla | 7085560 | 2017-08-28 13:40:32 -0400 | [diff] [blame] | 32 | /* add a back pointer in dl to bp */ |
| 33 | if (dl) { |
| 34 | struct bnxt_dl *bp_dl = devlink_priv(dl); |
| 35 | |
| 36 | bp_dl->bp = bp; |
| 37 | } |
Sathya Perla | 4ab0c6a | 2017-07-24 12:34:27 -0400 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | int bnxt_dl_register(struct bnxt *bp); |
| 41 | void bnxt_dl_unregister(struct bnxt *bp); |
| 42 | void bnxt_vf_reps_destroy(struct bnxt *bp); |
Sathya Perla | ee5c7fb | 2017-07-24 12:34:28 -0400 | [diff] [blame] | 43 | void bnxt_vf_reps_close(struct bnxt *bp); |
| 44 | void bnxt_vf_reps_open(struct bnxt *bp); |
| 45 | void bnxt_vf_rep_rx(struct bnxt *bp, struct sk_buff *skb); |
| 46 | struct net_device *bnxt_get_vf_rep(struct bnxt *bp, u16 cfa_code); |
Sathya Perla | 4ab0c6a | 2017-07-24 12:34:27 -0400 | [diff] [blame] | 47 | |
Sathya Perla | 2ae7408 | 2017-08-28 13:40:33 -0400 | [diff] [blame^] | 48 | static inline u16 bnxt_vf_rep_get_fid(struct net_device *dev) |
| 49 | { |
| 50 | struct bnxt_vf_rep *vf_rep = netdev_priv(dev); |
| 51 | struct bnxt *bp = vf_rep->bp; |
| 52 | |
| 53 | return bp->pf.vf[vf_rep->vf_idx].fw_fid; |
| 54 | } |
| 55 | |
Sathya Perla | d3e3bec | 2017-07-25 13:28:39 -0400 | [diff] [blame] | 56 | #else |
| 57 | |
| 58 | static inline int bnxt_dl_register(struct bnxt *bp) |
| 59 | { |
| 60 | return 0; |
| 61 | } |
| 62 | |
| 63 | static inline void bnxt_dl_unregister(struct bnxt *bp) |
| 64 | { |
| 65 | } |
| 66 | |
| 67 | static inline void bnxt_vf_reps_close(struct bnxt *bp) |
| 68 | { |
| 69 | } |
| 70 | |
| 71 | static inline void bnxt_vf_reps_open(struct bnxt *bp) |
| 72 | { |
| 73 | } |
| 74 | |
| 75 | static inline void bnxt_vf_rep_rx(struct bnxt *bp, struct sk_buff *skb) |
| 76 | { |
| 77 | } |
| 78 | |
| 79 | static inline struct net_device *bnxt_get_vf_rep(struct bnxt *bp, u16 cfa_code) |
| 80 | { |
| 81 | return NULL; |
| 82 | } |
| 83 | #endif /* CONFIG_BNXT_SRIOV */ |
Sathya Perla | 4ab0c6a | 2017-07-24 12:34:27 -0400 | [diff] [blame] | 84 | #endif /* BNXT_VFR_H */ |