On Wed, 2018-10-03 at 19:20 +0800, [email protected] wrote:

If you use bitmaps for the security CAM index tracking,

this:

> +u32 rtw_sec_installed_cam_num(struct rtw_sec_desc *sec)
> +{
> +     u32 cnt = 0;
> +     int i;
> +
> +     for (i = 0; i < sec->total_cam_num; i++)
> +             if (sec->cam_table[i].used)
> +                     cnt++;
> +
> +     return cnt;
> +}

becomes hweight(), and this:

> +int rtw_sec_get_free_cam(struct rtw_sec_desc *sec)
> +{
> +     int i;
> +
> +     /* if default key search is enabled, the first 4 cam entries
> +      * are used to direct map to group key with its key->key_idx, so
> +      * driver should use cam entries after 4 to install pairwise key
> +      */
> +     i = sec->default_key_search ? RTW_SEC_DEFAULT_KEY_NUM : 0;
> +     for (; i < sec->total_cam_num; i++)
> +             if (!sec->cam_table[i].used)
> +                     return i;
> +
> +     return i;
> +}

just find_next_zero_bit().

Your code hard-codes an assumption that default_key_search is true
though, afaict, so you can probably just remove that.

johannes

Reply via email to