ibmvnic: Use bitmap for LTB map_ids
authorSukadev Bhattiprolu <sukadev@linux.ibm.com>
Wed, 15 Sep 2021 03:52:56 +0000 (20:52 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 15 Sep 2021 10:12:24 +0000 (11:12 +0100)
commit129854f061d8925a259f29b16d82bc19a23cf377
tree7d09e5aaa735030314751f5260068ca9eac7622c
parent0d1af4fa71241104b8959f83974875dc52bc129f
ibmvnic: Use bitmap for LTB map_ids

In a follow-on patch, we will reuse long term buffers when possible.
When doing so we have to be careful to properly assign map ids. We
can no longer assign them sequentially because a lower map id may be
available and we could wrap at 255 and collide with an in-use map id.

Instead, use a bitmap to track active map ids and to find a free map id.
Don't need to take locks here since the map_id only changes during reset
and at that time only the reset worker thread should be using the adapter.

Noticed this when analyzing an error Dany Madden ran into with the
patch set.

Reported-by: Dany Madden <drt@linux.ibm.com>
Reviewed-by: Rick Lindsley <ricklind@linux.vnet.ibm.com>
Reviewed-by: Dany Madden <drt@linux.ibm.com>
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ibm/ibmvnic.c
drivers/net/ethernet/ibm/ibmvnic.h