core: mgbe: use lock for time stamping

Using lock for protect critical section between
common interrupt and ioctl call to read
timestamp

Add mmc counters for lock failure during node
addition and deletion.

Bug 200743666

Change-Id: I12a2e57993e91d6ed50ed0efc84d1b60ef736677
Signed-off-by: Rakesh Goyal <rgoyal@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/kernel/nvethernetrm/+/2590099
Tested-by: Gaurav Asati <gasati@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Gaurav Asati <gasati@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Nagarjuna Kristam <nkristam@nvidia.com>
Reviewed-by: Bhadram Varka <vbhadram@nvidia.com>
Reviewed-by: Krishna Thota <kthota@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Rakesh Goyal
2021-09-06 19:40:15 +05:30
committed by mobile promotions
parent 801815742d
commit a9b03b83a9
6 changed files with 33 additions and 1 deletions

View File

@@ -578,6 +578,10 @@ struct osi_xtra_stat_counters {
nveu64_t link_connect_count; nveu64_t link_connect_count;
/** link disconnect count */ /** link disconnect count */
nveu64_t link_disconnect_count; nveu64_t link_disconnect_count;
/** lock fail count node addition */
nveu64_t ts_lock_add_fail;
/** lock fail count node removal */
nveu64_t ts_lock_del_fail;
}; };
#ifdef MACSEC_SUPPORT #ifdef MACSEC_SUPPORT

View File

@@ -299,6 +299,8 @@ struct core_local {
nveu32_t gcl_dep; nveu32_t gcl_dep;
/** Max GCL width (time + gate) value supported by HW */ /** Max GCL width (time + gate) value supported by HW */
nveu32_t gcl_width_val; nveu32_t gcl_width_val;
/** TS lock */
nveu32_t ts_lock;
}; };
/** /**

View File

@@ -3270,6 +3270,15 @@ static void mgbe_handle_mac_intrs(struct osi_core_priv_data *osi_core,
if ((mac_isr & MGBE_ISR_TSIS) == MGBE_ISR_TSIS) { if ((mac_isr & MGBE_ISR_TSIS) == MGBE_ISR_TSIS) {
struct osi_core_tx_ts *head = &l_core->tx_ts_head; struct osi_core_tx_ts *head = &l_core->tx_ts_head;
if (__sync_fetch_and_add(&l_core->ts_lock, 1) == 1U) {
/* mask return as initial value is returned always */
(void)__sync_fetch_and_sub(&l_core->ts_lock, 1);
osi_core->xstats.ts_lock_add_fail =
osi_update_stats_counter(
osi_core->xstats.ts_lock_add_fail, 1U);
goto done;
}
/* TXTSC bit should get reset when all timestamp read */ /* TXTSC bit should get reset when all timestamp read */
while (((osi_readla(osi_core, (nveu8_t *)osi_core->base + while (((osi_readla(osi_core, (nveu8_t *)osi_core->base +
MGBE_MAC_TSS) & MGBE_MAC_TSS) &
@@ -3299,7 +3308,11 @@ static void mgbe_handle_mac_intrs(struct osi_core_priv_data *osi_core,
l_core->ts[i].prev = head->prev; l_core->ts[i].prev = head->prev;
head->prev = &l_core->ts[i]; head->prev = &l_core->ts[i];
} }
/* mask return as initial value is returned always */
(void)__sync_fetch_and_sub(&l_core->ts_lock, 1);
} }
done:
mac_isr &= ~MGBE_ISR_TSIS; mac_isr &= ~MGBE_ISR_TSIS;
osi_writela(osi_core, mac_isr, osi_writela(osi_core, mac_isr,

View File

@@ -167,6 +167,7 @@ nve32_t osi_init_core_ops(struct osi_core_priv_data *const osi_core)
return ret; return ret;
} }
l_core->if_init_done = OSI_ENABLE; l_core->if_init_done = OSI_ENABLE;
l_core->ts_lock = OSI_DISABLE;
return ret; return ret;
} }

View File

@@ -1425,6 +1425,15 @@ static inline nve32_t get_tx_ts(struct osi_core_priv_data *osi_core,
nve32_t ret = -1; nve32_t ret = -1;
nveu32_t count = 0U; nveu32_t count = 0U;
if (__sync_fetch_and_add(&l_core->ts_lock, 1) == 1U) {
/* mask return as initial value is returned always */
(void)__sync_fetch_and_sub(&l_core->ts_lock, 1);
osi_core->xstats.ts_lock_del_fail =
osi_update_stats_counter(
osi_core->xstats.ts_lock_del_fail, 1U);
goto done;
}
while ((temp != head) && (count < MAX_TX_TS_CNT)) { while ((temp != head) && (count < MAX_TX_TS_CNT)) {
if ((temp->pkt_id == ts->pkt_id) && if ((temp->pkt_id == ts->pkt_id) &&
(temp->in_use != OSI_NONE)) { (temp->in_use != OSI_NONE)) {
@@ -1442,6 +1451,9 @@ static inline nve32_t get_tx_ts(struct osi_core_priv_data *osi_core,
temp = temp->next; temp = temp->next;
} }
/* mask return as initial value is returned always */
(void)__sync_fetch_and_sub(&l_core->ts_lock, 1);
done:
return ret; return ret;
} }