Add reverse-variants of qed_chain_get_elem_left{,u32}() to be able to know current chain occupation. They will be used in the upcoming qede XDP_REDIRECT code. They share most of the logics with the mentioned ones, so were reused to collapse the latters.
Showing the changes to include/linux (1 of 1 file). Show all
Unified · Split
| @@ -203,7 +203,7 @@ static inline u32 qed_chain_get_cons_idx_u32(const struct qed_chain *chain) · 202 unmodified lines | ||
| 203 | 203 | return chain->u.chain32.cons_idx; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | −static inline u16 qed_chain_get_elem_left(const struct qed_chain *chain) | |
| 206 | +static inline u16 qed_chain_get_elem_used(const struct qed_chain *chain) | |
| 207 | 207 | { |
| 208 | 208 | u32 prod = qed_chain_get_prod_idx(chain); |
| 209 | 209 | u32 cons = qed_chain_get_cons_idx(chain); |
| @@ -217,10 +217,15 @@ static inline u16 qed_chain_get_elem_left(const struct qed_chain *chain) · 7 unmodified lines | ||
| 217 | 217 | if (chain->mode == QED_CHAIN_MODE_NEXT_PTR) |
| 218 | 218 | used -= (u16)(prod / elem_per_page - cons / elem_per_page); |
| 219 | 219 | |
| 220 | − return (u16)(chain->capacity - used); | |
| 220 | + return used; | |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | −static inline u32 qed_chain_get_elem_left_u32(const struct qed_chain *chain) | |
| 223 | +static inline u16 qed_chain_get_elem_left(const struct qed_chain *chain) | |
| 224 | +{ | |
| 225 | + return (u16)(chain->capacity - qed_chain_get_elem_used(chain)); | |
| 226 | +} | |
| 227 | + | |
| 228 | +static inline u32 qed_chain_get_elem_used_u32(const struct qed_chain *chain) | |
| 224 | 229 | { |
| 225 | 230 | u64 prod = qed_chain_get_prod_idx_u32(chain); |
| 226 | 231 | u64 cons = qed_chain_get_cons_idx_u32(chain); |
| @@ -234,7 +239,12 @@ static inline u32 qed_chain_get_elem_left_u32(const struct qed_chain *chain) · 7 unmodified lines | ||
| 234 | 239 | if (chain->mode == QED_CHAIN_MODE_NEXT_PTR) |
| 235 | 240 | used -= (u32)(prod / elem_per_page - cons / elem_per_page); |
| 236 | 241 | |
| 237 | − return chain->capacity - used; | |
| 242 | + return used; | |
| 243 | +} | |
| 244 | + | |
| 245 | +static inline u32 qed_chain_get_elem_left_u32(const struct qed_chain *chain) | |
| 246 | +{ | |
| 247 | + return chain->capacity - qed_chain_get_elem_used_u32(chain); | |
| 238 | 248 | } |
| 239 | 249 | |
| 240 | 250 | static inline u16 qed_chain_get_usable_per_page(const struct qed_chain *chain) |