📄 xp_osi_filte.c
字号:
/* if(filter->polarity[i]) { match = !match; } */ } } return(match);}/*----------------------------------------------------------------------------+| hw_filter_set+----------------------------------------------------------------------------*/static void hw_filter_set(GLOBAL_RESOURCES *pGlobal,FILTER_TYPE *pFilter){ unsigned short i, j; unsigned short hw_count; /* index into the hw_block_id */ unsigned long data; /* data portion of filter */ unsigned long mask; /* mask for the filter */ //added in 4/2002 unsigned long polarity; unsigned long control; /* filter control */ unsigned char *pData; unsigned char *pMask; unsigned char *pPolarity; pData = (unsigned char *) &data; pMask = (unsigned char *) &mask; pPolarity = (unsigned char *) &polarity; control = 0; data = 0; mask = 0; for(i=0, j=0, hw_count=0; i<pFilter->uwLength; i++) { /*--------------------------------------------------------------------+ | Skip bytes 1 & 2, add the byte to the word | When all four bytes of the word have been written, update hardware +--------------------------------------------------------------------*/ if((i == 1) || (i == 2)) { continue; } pData[j] = pFilter->cData[i]; pMask[j] = pFilter->cMask[i]; pPolarity[j] = pFilter->cPolarity[i]; j++; if(j == 4) { write_dram_filter(pGlobal, pFilter, hw_count, data, mask, control, polarity); hw_count++; j = 0; control = 0; } } /*------------------------------------------------------------------------+ | if there was not a multiple of 4 bytes to filter, then turn off the | remaining bytes and write the last filter +------------------------------------------------------------------------*/ if(j) { for(; j<4; j++) { pData[j] = 0; pMask[j] = 0; pPolarity[j] = 0xff; } write_dram_filter(pGlobal,pFilter, hw_count, data, mask, control, polarity); }}/*----------------------------------------------------------------------------+| hw_filter_add+----------------------------------------------------------------------------*/static short hw_filter_add(GLOBAL_RESOURCES *pGlobal, FILTER_CHANNEL_PTR pChannel, /* channel information */ SHORT wChannelId, FILTER_PTR pF2) /* new filter to add */{ unsigned short i; short id1; /* current hw index number */ short id2; /* current hw index number */ short prev; /* save the previous id. */ UINT32 flag; /*------------------------------------------------------------------------+ | Set the match_id for the filters +------------------------------------------------------------------------*/ for(i=0; i<pF2->uwHwBlockCount; i++) { flag = os_enter_critical_section(); xp_atom_dcr_write_register_channel(pGlobal->uDeviceIndex, XP_FILTER_CONTROL_REG_SFID, pF2->cHwBlockId[i], pF2->wMatchId); os_leave_critical_section(flag); } /*------------------------------------------------------------------------+ | If there are no filters defined to the channel, then just set the | first filter id. +------------------------------------------------------------------------*/ if(pChannel->wInuse == 0) { id2 = pF2->cHwBlockId[0]; pChannel->wFirstHwFilterId = id2; flag = os_enter_critical_section(); xp_atom_dcr_write_register_channel(pGlobal->uDeviceIndex, XP_QCONFIGB_REG_FSF, wChannelId, id2); os_leave_critical_section(flag); } else { /*--------------------------------------------------------------------+ | Traverse the chain, and at each endOfColumn, move both pointers | (id1, id2) to the next column until we reach the end of either | column. +--------------------------------------------------------------------*/ id1 = pChannel->wFirstHwFilterId; id2 = pF2->cHwBlockId[0]; while(pGlobal->FilterInfo.XpFilterHwData[id1].next != id1) { if (pGlobal->FilterInfo.XpFilterHwData[id1].endOfColumn) { if(pGlobal->FilterInfo.XpFilterHwData[id2].next == id2) { break; } id2 = pGlobal->FilterInfo.XpFilterHwData[id2].next; } id1 = pGlobal->FilterInfo.XpFilterHwData[id1].next; } /*--------------------------------------------------------------------+ | Now traverse backwards adding nodes to the hardware links +--------------------------------------------------------------------*/ while (pGlobal->FilterInfo.XpFilterHwData[id1].prev != id1) { if (pGlobal->FilterInfo.XpFilterHwData[id1].endOfColumn) { prev = pGlobal->FilterInfo.XpFilterHwData[id2].prev; update_links(pGlobal,id1, id2); id2 = prev; } id1 = pGlobal->FilterInfo.XpFilterHwData[id1].prev; } if (pGlobal->FilterInfo.XpFilterHwData[id1].endOfColumn) { update_links(pGlobal,id1, id2); } } return(0);}/*----------------------------------------------------------------------------+| hw_filter_delete+----------------------------------------------------------------------------*/static short hw_filter_delete(GLOBAL_RESOURCES *pGlobal,SHORT wChannelId, FILTER_PTR pF2) /* filter to delete */{ unsigned short i; short id; /* current filter_id */ short next; /* next filter_id in the list */ short prev=0; /* previous filter_id in the list */ FILTER_CHANNEL_PTR pChannel; /* channel information */ UINT32 flag; pChannel = &pGlobal->FilterInfo.XpFilterChData[wChannelId]; /*------------------------------------------------------------------------+ | Check if this is the first filter defined +------------------------------------------------------------------------*/ id = pF2->cHwBlockId[0]; i = 0; if(pChannel->wFirstHwFilterId == id) { flag = os_enter_critical_section(); xp_atom_dcr_write_register_channel(pGlobal->uDeviceIndex, XP_QCONFIGB_REG_FSF, wChannelId, pGlobal->FilterInfo.XpFilterHwData[id].next); os_leave_critical_section(flag); next = pGlobal->FilterInfo.XpFilterHwData[id].next; /*--------------------------------------------------------------------+ | Move the 1st filter for the channel to the next node +--------------------------------------------------------------------*/ pChannel->wFirstHwFilterId = next; pGlobal->FilterInfo.XpFilterHwData[next].prev = next; i++; } for(; i<pF2->uwHwBlockCount; i++) { id = pF2->cHwBlockId[i]; next = pGlobal->FilterInfo.XpFilterHwData[id].next; prev = pGlobal->FilterInfo.XpFilterHwData[id].prev; pGlobal->FilterInfo.XpFilterHwData[next].prev = prev; pGlobal->FilterInfo.XpFilterHwData[prev].next = next; if(pGlobal->FilterInfo.XpFilterHwData[id].endOfColumn) { pGlobal->FilterInfo.XpFilterHwData[prev].endOfColumn = 1; } /*--------------------------------------------------------------------+ | Update the hardware links +--------------------------------------------------------------------*/ flag = os_enter_critical_section(); xp_atom_dcr_write_filter_link(pGlobal->uDeviceIndex, prev, pGlobal->FilterInfo.XpFilterHwData[prev].next, pGlobal->FilterInfo.XpFilterHwData[prev].endOfColumn); os_leave_critical_section(flag); } /*------------------------------------------------------------------------+ | Check if the last node removed is also the last node in the list. | If so, then change the previous node to be the last node. | Update the hardware links +------------------------------------------------------------------------*/ if(pGlobal->FilterInfo.XpFilterHwData[id].next == id) { pGlobal->FilterInfo.XpFilterHwData[prev].next = prev; flag = os_enter_critical_section(); xp_atom_dcr_write_filter_link(pGlobal->uDeviceIndex, prev, pGlobal->FilterInfo.XpFilterHwData[prev].next, pGlobal->FilterInfo.XpFilterHwData[prev].endOfColumn); os_leave_critical_section(flag); } return(0);}/*----------------------------------------------------------------------------+| free_filter+----------------------------------------------------------------------------*/static void free_filter(GLOBAL_RESOURCES *pGlobal, SHORT wFilterId){ unsigned short i; FILTER_TYPE *pFilter; pFilter = pGlobal->FilterInfo.pXpFilterData[wFilterId]; for(i=0; i<pFilter->uwHwBlockCount; i++) { clear_hw_block(pGlobal,pFilter->cHwBlockId[i]); } FREE(pFilter); pGlobal->FilterInfo.pXpFilterData[wFilterId] = NULL;}/*----------------------------------------------------------------------------+| find_filter+----------------------------------------------------------------------------*/static SHORT find_filter(GLOBAL_RESOURCES *pGlobal,SHORT wChannelId,SHORT wFilterId, SHORT *pId) /* array index in channel array */{ short i; FILTER_CHANNEL_PTR pChannel; pChannel = &pGlobal->FilterInfo.XpFilterChData[wChannelId]; /*------------------------------------------------------------------------+ | Find the filter_id in the channel array +------------------------------------------------------------------------*/ for(i=0; i<pChannel->wCount; i++) { if(pChannel->wFilterId[i] == wFilterId) { break; } } if(i == pChannel->wCount) { return(XP_ERROR_FILTER_NOT_ASSIGN); } *pId = i; return(0);}/*----------------------------------------------------------------------------+| delete_filter+----------------------------------------------------------------------------*/static void delete_filter(GLOBAL_RESOURCES *pGlobal, SHORT wChannelId, SHORT wFilterId,short i){ FILTER_CHANNEL_PTR pChannel; FILTER_TYPE *pFilter; pChannel = &pGlobal->FilterInfo.XpFilterChData[wChannelId]; pFilter = pGlobal->FilterInfo.pXpFilterData[wFilterId]; /*------------------------------------------------------------------------+ | If this is the last filter defined to the channel, turn off the queue +------------------------------------------------------------------------*/ if(pChannel->wInuse == 1) { xp_osi_filter_control(pGlobal,pChannel->wFirstHwFilterId, XP_FILTER_CONTROL_DISABLE); } else { hw_filter_delete(pGlobal,wChannelId, pFilter); } /*------------------------------------------------------------------------+ | Re-initialize the software links for the standalone filter remove | the filter association with the channel +------------------------------------------------------------------------*/ init_filter_links(pGlobal,pFilter); pChannel->wFilterId[i] = FILTER_ID_UNUSED; if(pChannel->wInuse > 0) pChannel->wInuse--; pFilter->wChannelId = XP_CHANNEL_COUNT; pFilter->pending = PENDING_NONE;}/*----------------------------------------------------------------------------+| check_filters+----------------------------------------------------------------------------*/static void check_filters(GLOBAL_RESOURCES *pGlobal, SHORT wChannelId, XP_CHANNEL_NOTIFY_DATA *pInfo, UCHAR *plBQueue, UCHAR *plEQueue){ short i; short skip=0; SHORT wFilterId; short errorMatchWord=0; unsigned long mask; XP_FILTER_SHORT shortFilter; FILTER_CHANNEL_PTR pChannel; pChannel = &pGlobal->FilterInfo.XpFilterChData[wChannelId]; for (i=0, mask=0x80000000; i<32; i++, mask>>=1) { if (mask & pInfo->ulMatchWord)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -