+int cxgbe_mpstcam_rawf_enable(struct port_info *pi)
+{
+ struct adapter *adap = pi->adapter;
+ struct mps_tcam_entry *entry;
+ struct mpstcam_table *t;
+ u16 rawf_idx;
+ int ret = 0;
+
+ t = adap->mpstcam;
+ if (adap->params.rawf_size == 0 || t == NULL)
+ return -EOPNOTSUPP;
+
+ t4_os_write_lock(&t->lock);
+ rawf_idx = adap->params.rawf_start + pi->port_id;
+ entry = &t->entry[rawf_idx];
+ if (__atomic_load_n(&entry->refcnt, __ATOMIC_RELAXED) == 1)
+ goto out_unlock;
+
+ ret = t4_alloc_raw_mac_filt(adap, pi->viid, entry->eth_addr,
+ entry->mask, rawf_idx, 0, pi->port_id,
+ false);
+ if (ret < 0)
+ goto out_unlock;
+
+ __atomic_store_n(&entry->refcnt, 1, __ATOMIC_RELAXED);
+
+out_unlock:
+ t4_os_write_unlock(&t->lock);
+ return ret;
+}
+
+int cxgbe_mpstcam_rawf_disable(struct port_info *pi)
+{
+ struct adapter *adap = pi->adapter;
+ struct mps_tcam_entry *entry;
+ struct mpstcam_table *t;
+ u16 rawf_idx;
+ int ret = 0;
+
+ t = adap->mpstcam;
+ if (adap->params.rawf_size == 0 || t == NULL)
+ return -EOPNOTSUPP;
+
+ t4_os_write_lock(&t->lock);
+ rawf_idx = adap->params.rawf_start + pi->port_id;
+ entry = &t->entry[rawf_idx];
+ if (__atomic_load_n(&entry->refcnt, __ATOMIC_RELAXED) != 1)
+ goto out_unlock;
+
+ ret = t4_free_raw_mac_filt(adap, pi->viid, entry->eth_addr,
+ entry->mask, rawf_idx, 0, pi->port_id,
+ false);
+ if (ret < 0)
+ goto out_unlock;
+
+ __atomic_store_n(&entry->refcnt, 0, __ATOMIC_RELAXED);
+
+out_unlock:
+ t4_os_write_unlock(&t->lock);
+ return ret;
+}
+