0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

DS31256 非通道化T3/E3/HSSI/VDSL端口配置,適用于橋接模式應(yīng)用

星星科技指導(dǎo)員 ? 來源:ADI ? 作者:ADI ? 2023-06-16 17:29 ? 次閱讀

概述

本應(yīng)用筆記舉例說明如何在橋接模式下配置單個T3端口,在DS31256上進行非溝道化工作。此外,此示例還介紹如何在該端口上以環(huán)回模式構(gòu)造、發(fā)送、接收和檢查數(shù)據(jù)包。本應(yīng)用筆記作為編碼示例提供,以便于適應(yīng)最終用戶應(yīng)用。

DS31256本地總線工作在兩種模式:

  1. PCI 橋接模式
  2. 配置模式

PCI 橋接模式允許 PCI 總線上的主機訪問本地總線。PCI總線用于控制和監(jiān)視DS31256,并在此應(yīng)用中傳輸數(shù)據(jù)包數(shù)據(jù)。DS31256還配置為將數(shù)據(jù)從PCI總線映射到本地總線,用于控制和監(jiān)視xDSL調(diào)制解調(diào)器或T3/E3接口等外圍元件。

此示例具有以下配置:

  • DS1的端口31256作為非通道端口工作。也就是說,端口獲得接收/發(fā)送時鐘,但沒有同步脈沖。不使用所有其他端口。
  • HDLC通道0分配給DS1的端口31256。它還分配了 256 個 RX FIFO 塊、256 個 TX FIFO 塊、179 個 RX FIFO 高水位線(70 的 256%)和 77 個 TX 低水位線(30 的 256%)。
  • 使用 16 個 TX 緩沖區(qū)、10 個 TX 描述符和一個 TX 掛起隊列條目在主機內(nèi)存中構(gòu)造 10 個 10 字節(jié)數(shù)據(jù)包。TX 掛起隊列條目指向一個描述符,該描述符通過下一個描述符指針字段以及正在設(shè)置的 EOF 和 CV 鏈接到 <> 個描述符。
  • 由于DS31256處于環(huán)回模式,數(shù)據(jù)包在發(fā)送時也會被DS31256接收。接收到的數(shù)據(jù)包使用 10 個 RX 緩沖區(qū)、10 個 RX 描述符和 10 個 RX 完成隊列條目寫入主機內(nèi)存。
  • 主機內(nèi)存配置如下:
    • 接收端
      • RX 空閑隊列基址 (RFQBA1/0) = 0x10000000
      • RX 完成隊列基址 (RDQBA1/0) = 0x10000B00
      • RX 描述符基址 (RDBA1/0) = 0x10001080
      • RX 緩沖區(qū)基址 = 0x10002680
    • 傳輸側(cè)
      • TX 掛起隊列基址 (TPQBA1/0) = 0x10059084
      • TX 完成隊列基址 (TDQBA1/0) = 0x10059604
      • TX 描述符基址 (TDBA1/0) = 0x10059B84
      • TX 緩沖區(qū)基址 = 0x1005B184

編碼示例函數(shù)調(diào)用的定義

為了提高可讀性,此示例中的代碼使用了多個函數(shù)調(diào)用。這些函數(shù)的定義如下:

  • write_reg(地址、數(shù)據(jù))

    將指定數(shù)據(jù)寫入指定的DS31256寄存器地址

    輸入:地址=

    要寫入

    數(shù)據(jù)的寄存器地址 數(shù)據(jù)=要寫入指定寄存器

    的數(shù)據(jù) 輸出:無

  • read_reg(地址、數(shù)據(jù))

    在指定地址

    讀取DS31256寄存器的內(nèi)容 輸入:

    地址 = 要讀取

    的寄存器地址 輸出:

    數(shù)據(jù) = 從寄存器讀取的值

  • write_reg_IS(地址、數(shù)據(jù))

    將指定數(shù)據(jù)寫入指定的DS31256間接選擇寄存器,然后等待該寄存器的繁忙位清除后返回

    輸入: 地址 = 要寫入數(shù)據(jù)的間接選擇寄存器 數(shù)據(jù) = 要寫入

    指定寄存器

    的數(shù)據(jù) 輸出 : 無

    功能代碼 :

    write_reg(地址, 數(shù)據(jù));

    bit_check = 0x8000;

    而(bit_check&0x8000)

    read_reg(地址,bit_check);

  • wr_dword(地址、數(shù)據(jù))

    將指定的 32 位數(shù)據(jù)值寫入指定的 32 位主機內(nèi)存地址

    輸入:

    地址 = 要寫入數(shù)據(jù)的主機內(nèi)存地址 數(shù)據(jù) = 要寫入

    指定內(nèi)存地址

    的數(shù)據(jù) 輸出 : 無

  • rd_dword(地址、數(shù)據(jù))

    從指定的 32 位主機內(nèi)存地址

    讀取 32 位數(shù)據(jù)值 輸入:

    地址 = 要讀取

    的主機內(nèi)存地址 輸出:

    數(shù)據(jù) = 從主機內(nèi)存讀取的 32 位數(shù)據(jù)值

  • frame_wait(計數(shù))

    提供等于幀周期數(shù)的延遲,其中幀周期為 125μs

    輸入:計數(shù) = 等待

    的幀周期數(shù) 輸出 :

非通道化配置模式編碼示例

此編碼示例包括以下步驟:

  1. 復(fù)位DS31256
  2. 配置 DS31256
  3. 啟用 HDLC 通道
  4. 將 HDLC 通道置于環(huán)回模式
  5. 排隊、發(fā)送、接收和檢查數(shù)據(jù)包

以下各節(jié)通過簡要說明和編碼示例詳細(xì)介紹了其中每個步驟。使用寄存器名稱而不是地址來提高可讀性。DS31256內(nèi)部器件配置寄存器的相應(yīng)地址/失調(diào)列于附表中。此外,縮寫 TX 和 RX 分別用于表示發(fā)射端和接收端。請參考DS31256數(shù)據(jù)資料了解更多詳情。

復(fù)位DS31256

復(fù)位DS31256包括兩個步驟。首先,DS31256的內(nèi)部RAM必須歸零,然后復(fù)位DS31256內(nèi)部寄存器。

將DS31256內(nèi)部RAM歸零

DS31256內(nèi)部配置RAM不能通過復(fù)位芯片清除,因此必須手動歸零。該任務(wù)通過使用DS31256的適當(dāng)數(shù)據(jù)和間接選擇寄存器對DS31256中的每個內(nèi)部RAM進行一系列寫入來完成。本節(jié)詳細(xì)介紹了完成此任務(wù)的過程。

縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
CP[n]RDIS 03xx 通道化端口 n 寄存器數(shù)據(jù)間接選擇 6.3
CP[n]RD 03xx 信道化端口 n 寄存器數(shù)據(jù) 6.3
/* Zero RX configuration and TX configuration RAMs for all ports */
for(port = 0; port < 16; port = port + 1)
{
  write_reg(CP0RD + 8*port, 0x0000);
  for(ds0 = 0; ds0 < 128; ds0 = ds0 + 1)
  {
  	/* Set bits 9-8 = 01 to select RX Configuration RAM */
  	/* Set bits 9-8 = 10 to select TX Configuration RAM */
  	write_reg_IS(CP0RDIS + 8*port, (0x0100 + ds0));
  	write_reg_IS(CP0RDIS + 8*port, (0x0200 + ds0));
  }
}
縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
蕓香芷 0400 接收 HDLC 通道定義間接選擇 7.2
生殖健康發(fā)展 0404 接收 HDLC 通道定義 7.2
/* Zero the RX HDLC Channel Definition RAM */
write_reg(RHCD, 0x0000);
for(channel = 0; channel < 256; channel = channel + 1)
  write_reg_IS(RHCDIS, channel);
縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
西迪斯 0480 傳輸 HDLC 通道定義間接選擇 7.2
四氫大麻酚 0484 傳輸 HDLC 通道定義 7.2
/* Zero the TX HDLC Channel Definition RAM */
write_reg(THCD, 0x0000);
for(channel = 0; channel < 256; channel = channel + 1)
  write_reg_IS(THCDIS, channel);
縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
RFSBPIS 0900 接收 FIFO 凝視塊指針間接選擇 8.2
RFSBP 0904 接收先進先出起始塊指針 8.2
/* Zero the RX FIFO Starting Block Pointer RAM */
write_reg(RFSBP, 0x0000);
for(channel = 0; channel < 256; channel = channel + 1)
  write_reg_IS(RFSBPIS, channel);
縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
征求意見稿 0910 接收 FIFO 塊指針間接選擇 8.2
RFBP 0914 接收先進先出塊指針 8.2
/* Zero the RX FIFO Block Pointer RAM  */
write_reg(RFBP, 0x0000);
for(channel = 0; channel < 256; channel = channel + 1)
  write_reg_IS(RFBPIS, channel);
縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
RFHWMIS 0920 接收先進先出高水位線間接選擇 8.2
RFHWM 0924 接收先進先出高水位線 8.2
/* Zero the RX FIFO High Watermark RAM  */
write_reg(RFHWM, 0x0000);
for(channel = 0; channel < 256; channel = channel + 1)
  write_reg_IS(RFHWMIS, channel);
縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
TFSBPIS 0980 傳輸FIFO起始塊指針間接選擇 8.2
TFSBP 0984 傳輸先進先出起始塊指針 8.2
/* Zero the TX FIFO Starting Block Pointer Registers */
write_reg(TFSBP, 0x0000);
for(channel = 0; channel < 256; channel = channel + 1)
  write_reg_IS(TFSBPIS, channel);
縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
全要素計數(shù) 0990 傳輸 FIFO 塊指針間接選擇 8.2
全要素密度計 0994 傳輸先進先出塊指針 8.2
/* Zero the TX FIFO Block Pointer RAM */
write_reg(TFBP, 0x0000);
for(channel = 0; channel < 256; channel = channel + 1)
  write_reg_IS(TFBPIS, channel);
縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
TFLWMIS 09A0 傳輸 FIFO 塊指針間接選擇 8.2
TFLWM 09A4 傳輸先進先出低水位線 8.2
/* Zero the TX FIFO Low Watermark RAM */
write_reg(TFLWM, 0x0000);
for(channel = 0; channel < 256; channel = channel + 1)
  write_reg_IS(TFLWMIS, channel);
縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
RDMACIS 0770 接收 DMA 配置間接選擇 9.3.5
RDMAC 0774 接收 DMA 配置 9.3.5
/* Zero the RX DMA Configuration RAM */
write_reg(RDMAC, 0x0000);
for(channel = 0; channel < 256; channel = channel + 1)
  write_reg_IS(RDMACIS, 0x0400 + channel);
縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
道明西斯 0870 傳輸 DMA 配置間接選擇 8.2.5
道明 0874 傳輸 DMA 配置 8.2.5
/* Zero the TX DMA Configuration RAM */
write_reg(TDMAC, 0x0000);
for(channel = 0; channel < 256; channel = channel + 1)
  write_reg_IS(TDMACIS, 0x0400 + channel);

復(fù)位DS31256內(nèi)部寄存器

使用主復(fù)位寄存器(MRID)可以對DS31256中的所有寄存器執(zhí)行軟件復(fù)位。主機必須將此位設(shè)置回 0,然后才能對設(shè)備進行編程以使其正常運行。

縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
核磁共振成像 0000 主復(fù)位和ID寄存器 5.1
/* Reset DS31256 using MRID registers master reset bit. */
write_reg(MRID, 0x0001);
write_reg(MRID, 0x0000);

配置 DS31256

DS31256的配置包括以下步驟:

  1. 配置 PCI 寄存器
  2. 配置第 1 層寄存器
  3. 配置 HDLC 寄存器
  4. 配置 FIFO 寄存器
  5. 配置 DMA 寄存器

以下各節(jié)詳細(xì)介紹了每個寄存器集的配置。

/* This example uses port 1 channel 0 */
port = 1;
channel = 0;

/* RX free queue base address */
rfq_base_addr = 0x10000000;

/* RX free queue end address */
/* RX free queue size = 16 */
rfq_end_idx = 0x000F;

/* RX done queue base address */
rdq_base_addr = 0x10000B00;

/* RX done queue end address */
/* RX done queue size = 16 */
rdq_end_idx = 0x000F;

/* RX descriptor base address */
/* RX descriptor table size = 256 */
rdscr_base_addr = 0x10001080;

/* RX data buffer base address */
rx_buf_base_addr = 0x10002680;

/* TX pending queue base address */
tpq_base_addr = 0x10059084;

/* TX pending queue end address */
/* TX pending queue size = 16 */
tpq_end_idx = 0x000F;

/* TX done queue base address */
tdq_base_addr = 0x10059604;

/* TX done queue end address */
/* TX done queue size = 16 */
tdq_end_idx = 0x000F;

/* TX descriptor base address */
/* TX descriptor table size = 256 */
tdscr_base_addr = 0x10059B84;

/* TX data buffer base address */
tx_buf_base_addr = 0x1005B184;

配置 PCI 寄存器

PCI 橋接模式允許 PCI 總線上的主機訪問本地總線。PCI總線用于控制和監(jiān)視DS31256并傳輸數(shù)據(jù)包數(shù)據(jù)。DS31256將數(shù)據(jù)從PCI總線映射到本地總線。 (請參考DS10數(shù)據(jù)資料第31256節(jié))

縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
PCMD0 0x004/0A04 PCI 命令狀態(tài) 0 10.2
/* Map DS31256 configuration registers to a PCI Bus Base Address */
write_reg(PDCM, 0x80000000);

/* PCI command/status register 0 - controls DS31256 DMA functionality */
/* Set bit 1 = 1 to enable accesses to internal device configuration 
registers through PCI bus (required for bridge mode) */
/* Set bit 2 = 1 to allow the device operation as bus master on
PCI bus (required for DMA) */
/* Set bit 6 = 1 to act on parity errors */
/* Set bit 8 = 1 to enable the PSERR pin */
write_reg(PCMD0, 0x00000146);

配置第 1 層寄存器

DS31256的每個端口包含一個第1層控制器,執(zhí)行多種功能,包括:

  • 將 HDLC 通道號分配給傳入和傳出數(shù)據(jù)
  • 通道化本地和網(wǎng)絡(luò)環(huán)回
  • 通道化選擇 64kbps、56kbps 或無數(shù)據(jù)
  • 信道化發(fā)射DS0信道全部填充
  • 將數(shù)據(jù)路由到 BERT 函數(shù)和從 BERT 函數(shù)路由數(shù)據(jù)
  • 將數(shù)據(jù)路由到 V.54 環(huán)路模式檢測

第 1 層配置通過 RP[n]CR、TP[n]CR、CP[n]RD 和 CP[n]RDIS 寄存器在端口基礎(chǔ)上執(zhí)行,其中 n 是要配置的端口。

縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
RP[n]CR 01xx 接收端口 n 控制寄存器 6.2
TP[n]CR 02xx 傳輸端口 n 控制寄存器 6.2
CP[n]RDIS 03xx 通道化端口 n 寄存器數(shù)據(jù)間接選擇 6.3
CP[n]RD 03xx 信道化端口 n 寄存器數(shù)據(jù) 6.3
/* Set RX Port Control Register */
/* Set bits 2-0 = 000 for clock, data and sync are not inverted */
/* Set bits 5-4 = 00 for sync pulse 0 clocks early */
/* Bits 7-6 are ignored; the high-speed mode is enabled   */
/* Set bit 8 = 1 to enable high-speed mode */
/* Set bit 9 = 1 to enable unchannelized mode */
/* Set bit 10 = 0 to disable local loopback */
/* Bit 11 is not assigned */
/* Bits 12-13 are read only */
/* Set bit 14 = 0 to enable unchannelized mode */
/* Bit 15 is read only */
write_reg(RP0CR + 4*port, 0x0300);
/* Set TX Port Control Register */
/* Set bit 2-0 = 000 for clock, data and sync are not inverted */
/* Set bit 3 = 0 to force all data at TD to be 1 */
/* Set bits 5-4 = 00 for sync pulse 0 clocks early */
/* Bits 7-6 are ignored when the high-speed mode is enabled (TUEN=1)  */
/* Set bit 8 = 1 to enable high-speed mode */
/* Set bit 9 = 1 to enable unchannelized mode */
/* Set bit 10 = 0 to disable network loopback */
/* Set bit 11 = 0 to select source transmit data from the HDLC controller */
/* Bits 12-13 is not assigned */
/* Set bit 14 = 0 to mask interrupt */
/* Bit 15 is read only */
write_reg(TP0CR + 4*port, 0x0300);

配置 HDLC 寄存器

DS31256包含一個256通道HDLC控制器,執(zhí)行第2層功能,包括:

  • 零填料和去填料
  • 標(biāo)志檢測和字節(jié)對齊
  • CRC 生成和檢查
  • 數(shù)據(jù)反轉(zhuǎn)和位翻轉(zhuǎn)

HDLC控制器通過RHCD,RHCDIS,THCD和THCDIS寄存器基于通道進行配置。

縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
蕓香芷 0400 接收 HDLC 通道定義間接選擇 7.2
生殖健康發(fā)展 0404 接收 HDLC 通道定義 7.2
西迪斯 0480 傳輸 HDLC 通道定義間接選擇 7.2
四氫大麻酚 0484 傳輸 HDLC 通道定義 7.2
/* RX HDLC configuration */
/* Set bits 3-2 = 10 for 32-bit CRC */
write_reg(RHCD, 0x0008);
write_reg_IS(RHCDIS, channel);

/* TX HDLC Configuration */
/* Set bit 1= 0 to select an interfill byte of 7E */
/* Set bits 3-2 = 10 for 32-bit CRC */
/* Set bits 11-8 = 0000 share closing and opening flag */
write_reg(THCD, 0x0008);
write_reg_IS(THCDIS, channel);

配置 FIFO 寄存器

DS31256包含一個16k字節(jié)的發(fā)送FIFO和一個16kby的接收FIFO。每個FIFO分為1024個塊,每個塊四個雙字(dwords)或16個字節(jié)。FIFO 內(nèi)存基于HDLC通道進行分配。分配給每個 HDLC 通道的 FIFO 內(nèi)存量是可編程的,最小可以是四個塊,最多可以是 1024 個塊。FIFO內(nèi)存通過從一組塊中創(chuàng)建循環(huán)鏈接列表來分配給HDLC通道,其中每個塊指向鏈中的下一個塊,最后一個塊指向第一個塊。FIFO 塊鏈表通過分配鏈表中的一個塊作為該通道的 FIFO 起始塊指針來分配給特定的 HDLC 通道。

在此示例中,將 256 個 TX FIFO 塊和 256 個 RX FIFO 塊分配給 HDLC 通道。此示例還使用 RX FIFO 高水位線 179 和 TX FIFO 低水位線 77。RX FIFO 高水位線指示在 DMA 開始將數(shù)據(jù)發(fā)送到 PCI 總線之前,HDLC 引擎應(yīng)將多少塊寫入 RX FIFO。高水位線設(shè)置必須在一個塊之間,并且小于所涉及的特定通道的鏈接列表鏈中的塊數(shù)。TX FIFO 低水位線指示在 DMA 開始從 PCI 總線獲取更多數(shù)據(jù)之前,TX FIFO 中應(yīng)保留多少塊。HDLC 通道為防止發(fā)生傳輸下溢和接收溢出而需要的 FIFO 內(nèi)存量、RX FIFO 高水位線和 TX FIFO 低水位線量取決于應(yīng)用。請注意,水印選擇通常需要優(yōu)化,并且非常依賴于應(yīng)用程序。通常,將高水位線和低水位線都設(shè)置為 50% 是一個很好的起點。最后,DS31256的TX FIFO和RX FIFO通過下表中列出的寄存器在HDLC通道的基礎(chǔ)上獨立配置。

縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
蕓香芷 0910 RFBPIS 接收 FIFO 塊指針間接選擇 7.2
生殖健康發(fā)展 0914 RFBP 接收 FIFO 塊指針 7.2
/* Build the RX FIFO block linked list  0- >1- >2- >3- >4 ... 255 - > 0 */
for (block = 0; block < 255; block = block + 1)
{
/* Bits 9-0 in RFBP register indicate which block is next in the linked list */
write_reg(RFBP, block + 1);
write_reg_IS(RFBPIS, block);
}

/* The last block points to the first block to create a circular linked list */
write_reg(RFBP, 0x0000);
write_reg_IS(RFBPIS, 0x00FF);

/* Assign the circular linked list to a specific channel */
write_reg(RFSBP, 0x0000);
write_reg_IS(RFSBPIS, channel);
縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
RFHWMIS 0920 接收先進先出高水位線間接選擇 8.2
RFHWM 0924 接收先進先出高水位線 8.2
/* Set RX FIFO high watermark for channel to 179 */
write_reg(RFHWM, 0x00B3);
write_reg_IS(RFHWMIS, channel);
縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
全要素計數(shù) 0990 傳輸 FIFO 塊指針間接選擇 8.2
全要素密度計 0994 傳輸先進先出塊指針 8.2
/* TX FIFO block linked list 0- >1- >2- >3- >4 ... 255- >0 */
for(block = 0; block < 255; block = block + 1)
{
/* Bits 9-0 in RFBP register indicate which block is next in the linked list */
write_reg(TFBP, block + 1);
write_reg_IS(TFBPIS, block);
}

/* The last block points to the first block to create a circular linked list */
write_reg(TFBP, 0x0000);
write_reg_IS(TFBPIS, 0x00FF);
縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
TFSBPIS 0980 傳輸FIFO起始塊指針間接選擇 8.2
TFSBP 0984 傳輸先進先出起始塊指針 8.2
/* Assign the circular linked list to a specific channel */
write_reg(TFSBP, 0x0000);
write_reg_IS(TFSBPIS, channel);

/* Set TX FIFO low watermark for channel to 77 */
write_reg(TFLWM, 0x004D);
write_reg_IS(TFLWMIS, channel);

配置 DMA 寄存器

DMA 塊處理數(shù)據(jù)包數(shù)據(jù)從 FIFO 塊到 PCI 塊的傳輸,反之亦然。PCI模塊控制DS31256和外部PCI總線之間的數(shù)據(jù)傳輸。主機定義為位于PCI總線上的CPU智能控制器,指示DS31256如何處理傳入和傳出數(shù)據(jù)。

這是使用描述符完成的,這些描述符定義為從主機傳遞到 DMA 塊的預(yù)格式化消息,反之亦然。通過這些描述符,主機通知 DMA 要傳輸?shù)臄?shù)據(jù)包數(shù)據(jù)的位置和狀態(tài),以及接收的數(shù)據(jù)包數(shù)據(jù)的放置位置。DMA 使用這些描述符告訴主機已傳輸?shù)臄?shù)據(jù)包數(shù)據(jù)的狀態(tài)以及已接收的數(shù)據(jù)包數(shù)據(jù)的狀態(tài)和位置。

在接收端,主機將寫入空閑隊列描述符,通知 DMA 它可以將傳入數(shù)據(jù)包數(shù)據(jù)放置在何處。與每個空閑隊列條目相關(guān)聯(lián)的是接收數(shù)據(jù)緩沖區(qū)位置和數(shù)據(jù)包描述符。由于DS31256使用免接收隊列條目將接收到的數(shù)據(jù)包數(shù)據(jù)寫入主機存儲器,因此它會在RX done隊列中創(chuàng)建條目。這些 RX 完成隊列條目通知主機接收數(shù)據(jù)的位置和狀態(tài)。請參考DS31256數(shù)據(jù)資料了解更多詳情。主機必須通過寫入下表中的所有寄存器來配置 RX DMA:

縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
詢價單0 0700 接收免費隊列基址 0(小字) 9.2.3
詢價單1 0704 接收空閑隊列基址 1(大字) 9.2.3
詢價 0708 接收免費隊列結(jié)束地址 9.2.3
詢價單 070C 接收免費的小緩沖區(qū)起始地址 9.2.3
詢價 0710 接收空閑隊列大型緩沖區(qū)主機寫入指針 9.2.3
FQSBWP 0714 接收空閑隊列小型緩沖區(qū)主機寫入指針 9.2.3
詢價 0718 接收空閑隊列大緩沖區(qū) DMA 讀取指針 9.2.3
詢價 071C 接收空閑隊列小緩沖區(qū) DMA 讀取指針 9.2.3
RDQBA0 0730 接收完成隊列基址 0(小字) 9.2.4
RDQBA1 0734 接收完成隊列基址 1(大字) 9.2.4
德庫亞 0738 接收完成隊列結(jié)束地址 9.2.4
RDQRP 073C 接收完成隊列主機讀取指針 9.2.4
RDQWP 0740 接收完成隊列 DMA 寫入指針 9.2.4
RDBA0 0750 接收描述符基址 0(小字) 9.2.2
RDBA1 0754 接收描述符基址 1(大字) 9.2.2
RDMACIS 0770 接收 DMA 配置間接選擇 9.3.5
RDMAC 0774 接收 DMA 配置 9.3.5
利比斯 0790 接收較大的緩沖區(qū)大小 9.2.1
/* RX large buffer size = 256 bytes */
write_reg(RLBS, 0x0100);

/* RX free queue base address */
write_reg(RFQBA0, rfq_base_addr & 0x0000FFFF);
write_reg(RFQBA1, (rfq_base_addr > > 16) & 0x0000FFFF);

/* RX free queue large buffer read and write pointers = 0 */
write_reg(RFQLBRP, 0x0000);
write_reg(RFQLBWP, 0x0000);

/* RX free queue small buffer start address = 16 */
write_reg(RFQSBSA, rfq_end_idx);
/* RX free queue small buffer read and write pointers = 0 */
write_reg(RFQSBRP, 0x0000);
write_reg(RFQSBWP, 0x0000);

/* RX free queue end address */
write_reg(RFQEA, rfq_end_idx);

/* RX done queue base address */
write_reg(RDQBA0, rdq_base_addr & 0x0000FFFF);
write_reg(RDQBA1, (rdq_base_addr > > 16) & 0x0000FFFF);

/* RX done queue read and write pointers = 0 */
write_reg(RDQRP, 0x0000);
write_reg(RDQWP, 0x0000);

/* RX done queue end address */
write_reg(RDQEA, rdq_end_idx);

/* RX descriptor base address */
write_reg(RDBA0, rdscr_base_addr & 0x0000FFFF);
write_reg(RDBA1, (rdscr_base_addr > > 16) & 0x0000FFFF);

/* RX DMA Channel Configuration */
/* The data in RDMAC register is written to or read from the Receive Configuration RAM */
/* Set bit 0 = 0 to disable the HDLC Channel */
/* Set bit 2-1 = 00 for large buffers only */
/* Set bit 6-3 = 0000 for 0 byte offset from the data buffer address of the first data buffer */
/* Set bit 9-7 = 000 for DMA write to the done queue only after packet reception is complete */
/* Set the HDLC channel number by RDMACIS register */
write_reg(RDMAC, 0x0000);
write_reg_IS(RDMACIS, 0x0400 + channel);

在傳輸端,主機將寫入掛起的隊列,通知 DMA 哪些通道具有準(zhǔn)備傳輸?shù)臄?shù)據(jù)包數(shù)據(jù)。與每個掛起隊列描述符關(guān)聯(lián)的是描述數(shù)據(jù)包數(shù)據(jù)的一個或多個傳輸數(shù)據(jù)包描述符的鏈接列表。這些傳輸數(shù)據(jù)包描述符中的每一個還具有指向傳輸數(shù)據(jù)緩沖區(qū)的指針,該緩沖區(qū)包含 HDLC 數(shù)據(jù)包的實際數(shù)據(jù)有效負(fù)載。

當(dāng)DS31256處理傳輸暫掛隊列描述符條目時,它會創(chuàng)建傳輸完成的隊列描述符隊列條目。DMA在完成傳輸完整數(shù)據(jù)包或數(shù)據(jù)緩沖區(qū)后將寫入完成隊列,具體取決于DS31256的配置方式。通過這些完成隊列描述符,DMA 通知主機傳出數(shù)據(jù)包數(shù)據(jù)的狀態(tài)。請參考DS31256數(shù)據(jù)資料了解更多詳情。主機必須通過寫入下表中的所有寄存器來配置 TX DMA:

縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
TPQBA0 0800 傳輸掛起隊列基址 0(小字) 9.3.3
TPQBA1 0804 傳輸掛起隊列基址 1(大字) 9.3.3
TPQEA 0808 傳輸掛起隊列結(jié)束地址 9.3.3
TPQWP 080C 傳輸掛起隊列主機寫入指針 9.3.3
TPQRP 0810 傳輸掛起隊列 DMA 讀取指針 9.3.3
TDQBA0 0830 傳輸完成隊列基址 0(小字) 9.3.4
TDQBA1 0834 傳輸完成隊列基址 1(大字) 9.3.4
TDQEA 0838 傳輸完成隊列結(jié)束地址 9.3.4
TDQRP 083C 傳輸完成隊列主機讀取指針 9.3.4
TDQWP 0840 傳輸完成隊列 DMA 寫入指針 9.3.4
TDBA0 0850 傳輸描述符基址 0(小字) 9.3.2
TDBA1 0854 傳輸描述符基址 1(大字) 9.3.2
道明西斯 0870 傳輸 DMA 配置間接選擇 9.3.5
道明 0874 傳輸 DMA 配置 9.3.5
/* TX pending queue base address */
write_reg(TPQBA0, tpq_base_addr & 0x0000FFFF);
write_reg(TPQBA1, (tpq_base_addr > > 16) & 0x0000FFFF);

/* TX pending queue read and write pointers = 0 */
write_reg(TPQRP, 0x0000);
write_reg(TPQWP, 0x0000);

/* TX pending queue end address */
write_reg(TPQEA, tpq_end_idx);

/* TX done queue base address */
write_reg(TDQBA0, tdq_base_addr & 0x0000FFFF);
write_reg(TDQBA1, (tdq_base_addr > > 16) & 0x0000FFFF);

/* TX done-queue read and write pointers = 0 */
write_reg(TDQRP, 0x0000);
write_reg(TDQWP, 0x0000);

/* TX done-queue end address */
write_reg(TDQEA, tdq_end_idx);

/* TX descriptor base address */
write_reg(TDBA0, tdscr_base_addr & 0x0000FFFF);
write_reg(TDBA1, (tdscr_base_addr > > 16) & 0x0000FFFF);

/* TX DMA Channel Configuration */
/* The data in TDMAC register is written to or read from the Receive Configuration RAM */
/* Set bit 0 = 0 to disable HDLC Channel */
/* Set bit 1 = 0 for write done queue after packet transmitted */
/* Set the HDLC Channel Number by TDMACIS register */
write_reg(TDMAC, 0x0000);
write_reg_IS(TDMACIS, 0x0200 + channel);

啟用 HDLC 通道

DS31256初始化后的下一步是使能HDLC通道。除了上述配置步驟外,還必須執(zhí)行以下步驟才能在DS31256中實現(xiàn)數(shù)據(jù)包發(fā)送和接收:

  1. 在端口 TX 和 RX 配置 RAM 中啟用通道
  2. 在第 1 層啟用端口數(shù)據(jù)傳輸
  3. 為DS31256啟用TX DMA和RX DMA
  4. 啟用 HDLC 通道 TX DMA 和 RX DMA
縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
司儀 0010 主配置寄存器 5.2
TP[n]CR 02xx 傳輸端口 n 控制寄存器 6.2
RDMACIS 0770 接收 DMA 配置間接選擇寄存器 9.3.5
RDMAC 0774 接收 DMA 配置寄存器 9.3.5
道明西斯 0870 傳輸 DMA 配置間接選擇寄存器 9.3.5
道明 0874 傳輸 DMA 配置間接選擇寄存器 9.3.5
/* TX port control register */
/* Set bit 3 = 1 to allow data to be transmitted normally */
read_reg(TP0CR + 4*port, data);
write_reg(TP0CR + 4*port, data | 0x0008);

/* Enable TX and RX DMA in the DS31256 master configuration register */
/* Set bit 0 = 1 to enable Receive DMA */
/* Set bits 2-1 = 00 to burst length maximum is 32 dwords.  The optimum length */
/*                                       is application-dependent. */
/* Set bit 3 = 1 to enable Transmit DMA */
/* Set bit 6 = 1 for HDLC packet data on PCI bus is big endian */
/* Set bits 11-7 = 00000 to give Port 0 the dedicated resources of the BERT */
write_reg(MC, 0x0049);

/* Read the current channel value from the RX DMA Configuration RAM */
/* Set RDMACIS bits 7-0 = channel */
/* Set RDMACIS bits 10-8 = 100 to read lower word of dword 2 */
/* Set RDMACIS bit 14 = 1 to read from RAM */
write_reg_IS(RDMACIS, 0x4400 + channel);
read_reg(RDMAC, data);

/* Enable channel RX DMA */
/* Update RAM with new value */
/* Set RDMAC bit 0 = 1 to enable the HDLC channel */
/* Set RDMACIS bits 7-0 = channel */
/* Set RDMACIS bits 10-8 = 100 to write lower word of dword 2 */
/* Set RDMACIS bit 14 = 0 to write to RAM */
write_reg(RDMAC, data | 0x0001);
write_reg_IS(RDMACIS, 0x0400 + channel);

/* Read the current channel value from the TX DMA Configuration RAM */
/* Set TDMACIS bits 7-0 = channel */
/* Set TDMACIS bits 11-8 = 0010 to read lower word of dword 1 */
/* Set TDMACIS bit 14 = 1 to read from RAM */
write_reg_IS(TDMACIS, 0x4200 + channel);
read_reg(TDMAC, data);

/* Enable channel TX DMA */
/* Update RAM with new value */
/* Set TDMAC bit 0 = 1 to enable the HDLC channel */
/* Set TDMACIS bits 7-0 = channel */
/* Set TDMACIS bits 11-8 = 0010 to write lower word of dword 1 */
/* Set TDMACIS bit 14 = 0 to write to RAM */
write_reg((TDMAC, data | 0x0001);
write_reg_IS(TDMACIS, 0x0200 + channel);

將 HDLC 通道置于環(huán)回模式

配置并啟用通道后,DS625的內(nèi)部邏輯大約需要31256幀周期(<>μs)才能完成向新配置的轉(zhuǎn)換。一旦此轉(zhuǎn)換完成,HDLC通道就可以置于環(huán)回模式,以便在該通道上傳輸?shù)乃袛?shù)據(jù)也將在該通道上接收。在五幀等待期之前將 HDLC 通道置于環(huán)回模式可能會導(dǎo)致將垃圾數(shù)據(jù)寫入通道的 RX FIFO。

縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
RP[n]CR 01xx 接收端口 n 控制寄存器 6.2
/* Wait for at least five frame periods for the internal DS31256 initialization to complete */
frame_wait(5);

/* Set bit 10 = 1 to enable loopback - routes transmit data back to the receive port */
read_reg(RP0CR + 4*port, data);
write_reg(RP0CR + 4*port, data | 0x0400);

排隊、發(fā)送、接收和檢查數(shù)據(jù)包

DS31256初始化完成后,即可發(fā)送和接收數(shù)據(jù)。由于DS31256處于環(huán)回模式,HDLC通道上傳輸?shù)乃袛?shù)據(jù)也將在該通道上接收。本節(jié)介紹如何在主機內(nèi)存中構(gòu)建數(shù)據(jù)包、發(fā)送和接收數(shù)據(jù)包以及檢查結(jié)果的過程。以下各節(jié)詳細(xì)介紹了此過程。

初始化 RX 空閑隊列

在DS31256將接收到的數(shù)據(jù)包從內(nèi)部FIFO傳輸?shù)街鳈C存儲器之前,主機必須指示DS31256將數(shù)據(jù)放在哪里。這是通過 RX 空閑隊列完成的。RX 空閑隊列中的每個條目都包含一個指向 RX 數(shù)據(jù)緩沖區(qū)的指針和一個 RX 數(shù)據(jù)包描述符索引。此示例使用 10 個 RX 空閑隊列條目。每個條目包含一個 RX 空閑隊列大型緩沖區(qū)和一個 RX 數(shù)據(jù)包描述符。DS31256 RX大數(shù)據(jù)緩沖區(qū)大小設(shè)置為256字節(jié)(RLBS = 256)。此外,DS31256配置為使用4字節(jié)CRC,并將RX CRC寫入RX數(shù)據(jù)緩沖器。因此,一個 RX 大數(shù)據(jù)緩沖區(qū)能夠容納多達 252 字節(jié)的數(shù)據(jù)包數(shù)據(jù)。

縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
詢價 0710 接收空閑隊列大型緩沖區(qū)主機寫入指針 9.2.3
詢價 0718 接收空閑隊列大緩沖區(qū) DMA 讀取指針 9.2.3
/* check for space in RX large free queue */
read_reg(RFQLBWP, wr_ptr);
read_reg(RFQLBRP, rd_ptr);
if (rd_ptr > wr_ptr)
cnt = rd_ptr - wr_ptr - 1;
else
cnt = rfq_end_idx - wr_ptr + rd_ptr;

/* If room in RX free queue then put 10 entries in the queue */
/* dword 0 = RX data buffer address */
/* (use RX data buffer starting at RX buffer area base address) */
/* dword 1 = corresponding RX descriptor index (use RX descriptor table index 0) */
if (cnt > 9)
{
rx_dscr_idx = 0;
for (index=0, index < 10, index++)
{
wr_dword(rfq_base_addr + wr_ptr*8, rx_buf_base_addr+index*256);
wr_dword(rfq_base_addr + wr_ptr*8+4, index);
if (wr_ptr == rfq_end_idx)
wr_ptr = 0;
else
wr_ptr++;
}
/* Advance the RX free queue large buffer write pointer by 10 */
write_reg(RFQLBWP, wr_ptr);
}

在主機內(nèi)存中構(gòu)建數(shù)據(jù)包

此示例將發(fā)送 10 個 16 字節(jié)數(shù)據(jù)包的鏈。在發(fā)送數(shù)據(jù)包之前,必須在主機內(nèi)存中構(gòu)造數(shù)據(jù)包。此外,還必須在主機內(nèi)存中構(gòu)造相應(yīng)的 TX 數(shù)據(jù)包描述符。以下代碼詳細(xì)介紹了其中每個任務(wù)。

/* Create a 16-byte data packet in memory in a TX buffer whose 
start address is the TX buffer area base address */
wr_dword(tx_buf_base_addr,   0x01234567);
wr_dword(tx_buf_base_addr + 4, 0x89ABCDEF);
wr_dword(tx_buf_base_addr + 8, 0x02468ACE);
wr_dword(tx_buf_base_addr + 12, 0x13579BDF);

/* Second data packet goes in second data buffer 
(16-byte packet in 256-byte buffer). */
wr_dword(tx_buf_base_addr + 256, 0x08192A3B);
wr_dword(tx_buf_base_addr + 256 + 4, 0x4D5E6F70);
wr_dword(tx_buf_base_addr + 256 + 8, 0x8192A3B4);
wr_dword(tx_buf_base_addr + 256 + 12, 0xC5D6E7F8);

/* Create 8 more packets with unique data in each. */
for (index = 2, index < 10, index++)
{
wr_dword(tx_buf_base_addr + index*256, 	    0x08192A30  + index);
wr_dword(tx_buf_base_addr + index*256 + 4,   0x4D5E6F71  + index);
wr_dword(tx_buf_base_addr + index*256 + 8,   0x8192A3B2  + index);
wr_dword(tx_buf_base_addr + index*256 + 12, 0xC5D6E7F3 + index);
}

Create 10 TX Descriptors (4 dwords each)
/* TX descriptor table index 0 */
/* dword0 = TX buffer address */
/* dword1 = EOF, CV, byte count (10h), next descriptor pointer */
/* dword2 = HDLC channel */
/* dword3 = PV, next pending descriptor pointer (set to 0) */
tx_dscr_idx = 0;
for (index = 0, index < 10, index++)
{
wr_dword(tdscr_base_addr + index*16, tx_buf_base_addr+index*256);
if (index == 9)
wr_dword(tdscr_base_addr + index*16 + 4, 0x80100000);
/* end of chain, CV set to 0 */
else
wr_dword(tdscr_base_addr + index*16 + 4, 0xC0100000 + index+1);

wr_dword(tdscr_base_addr + index*16 + 8, 0x00000000 + channel);
wr_dword(tdscr_base_addr + index*16 + 12, 0x00000000);
}
/* This creates 10 TX descriptors that are chained or linked 
together via the next descriptor pointer. */

發(fā)送和接收數(shù)據(jù)包

要傳輸數(shù)據(jù)包,必須將 TX 描述符放在傳輸掛起隊列中,然后必須遞增傳輸掛起隊列寫入指針 (TPQWP)。當(dāng)DS31256檢測到待處理隊列不為空(TPQWP不等于TPQRP)時,它將開始處理隊列條目并傳輸數(shù)據(jù)包。

縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
SDMA 0028 DMA 的狀態(tài)寄存器 5.3.2
TPQWP 080C 傳輸掛起隊列主機寫入指針 9.3.3
TPQRP 0810 傳輸掛起隊列 DMA 讀取指針 9.3.3
/* Read SDMA register to clear any previously set status bits */
read_reg(SDMA, data);

Write the TX Pending-Queue Entry
/* check free space in TX pending queue */
read_reg(TPQWP, wr_ptr);
read_reg(TPQRP, rd_ptr)
if (rd_ptr > wr_ptr)
cnt = rd_ptr - wr_ptr - 1;
else
cnt = rfq_end_idx - wr_ptr + rd_ptr;

/* If room in the TX pending queue create an entry for the packet */
if (cnt > 0)
{
/* Bits 0-15 Descriptor Pointer (0000h) */
/* Bits 16-23 HDLC channel - (channel < < 16) */
wr_dword(tpq_base_addr + wr_ptr*4, 0x0000000 + (channel < < 16));

/* Advance the TX pending-queue write pointer */
if (wr_ptr == tpq_end_idx)
wr_ptr = 0;
else
wr_ptr = wr_ptr + 1;
write_reg(TPQWP, wr_ptr);
}

檢查結(jié)果

在等待足夠的時間傳輸和接收數(shù)據(jù)包后,可以執(zhí)行多項檢查以確定數(shù)據(jù)包傳輸和接收是否成功。以下代碼詳細(xì)介紹了這些檢查。

縮寫 偏移量/地址 寄存器名稱 數(shù)據(jù)表部分
SDMA 0028 DMA 的狀態(tài)寄存器 5.3.2
詢價 0710 接收空閑隊列大型緩沖區(qū)主機寫入指針 9.2.3
詢價 0718 接收空閑隊列大緩沖區(qū) DMA 讀取指針 9.2.3
RDQRP 073C 接收完成隊列主機讀取指針 9.2.4
RDQWP 0740 接收完成隊列 DMA 寫入指針 9.2.4
TDQRP 083C 傳輸完成隊列主機讀取指針 9.3.4
TDQWP 0840 傳輸完成隊列 DMA 寫入指針 9.3.4
/* Wait two frame periods for packet to be transmitted/received */
frame_wait(2);
/* Check SDMA register, Expected value = 0x6440; if not, it means there was error */
read_reg(SDMA, data);

/* Check to see how many entries are in the TX done queue 
(distance from TDQRP to TDQWP) */
/* Expected value is 0Ah - 10 entries in the TX done queue 
corresponding to the 10 packets that were sent */
read_reg(TDQRP, rd_ptr);
read_reg(TDQWP, wr_ptr);
if (wr_ptr >= rd_ptr)
cnt = wr_ptr - rd_ptr;
else
cnt = tdq_end_idx + 1 - rd_ptr + wr_ptr;

/* Check TX done-queue descriptor */
/* Expected value = 0x00000000 */
/* Bits 15-0 indicates the descriptor pointer */
/* Bits 23-16 indicate the channel number, it should be 0 in this example */
/* Bits 28-26 indicate the packet status, all 0 means the packet 
transmission is complete and the descriptor */
/* Pointer field corresponds to the first descriptor in the HDLC 
packet that has been transmitted */
for (index = 0; index < 10; index++)
{
rd_dword(tdq_base_addr + rd_ptr*4, tdq_entry);
/* Advance the TX done-queue read pointer */
if (rd_ptr == tdq_end_idx)
rd_ptr = 0;
else
rd_ptr = rd_ptr + 1;
write_reg(TDQRP, rd_ptr);
}

/* Check the RX large free queue to see how many RX buffers are 
in the queue (distance from RFQLBRP to RFQLBWP) */
/* Expected number is 0 since the queue had 10 buffers before the 
packet was received and packet reception required 10 buffers */
read_reg(RFQLBRP, rd_ptr);
read_reg(RFQLBWP, wr_ptr);
if (wr_ptr >= rd_ptr)
cnt = wr_ptr - rd_ptr;
else
cnt = rfq_end_idx + 1 - rd_ptr + wr_ptr;

/* Check RX done queue to see if any packets were received (distance from RDQRP to RDQWP)
Expected value is 10 - 10 entries in the RX done-queue entry corresponding to 
the 10 packets that should have been received */
read_reg(RDQRP, rd_ptr);
read_reg(RDQWP, wr_ptr);
if (wr_ptr >= rd_ptr)
cnt = wr_ptr - rd_ptr;
else
cnt = rdq_end_idx + 1 - rd_ptr + wr_ptr;

/* Check the RX done queue descriptor */
/* Expected value = 0x40000000, */
/* Bits 15-0 indicates the descriptor pointer */
/* Bits 23-16 indicate the channel number; it should be 0 in this example */
/* Bits 26-24 indicate the buffer count; all 0 means that a complete packet has been received */
/* Bit 30 EOF = 1 indicates the receiver descriptor is the last one in the chain */
for (index = 0;index < 10;index++)
/* Check all 10 entries */
{
rd_dword(rdq_base_addr + 8*rd_ptr, rdq_entry);

/* Check the corresponding RX descriptor (4 dwords) */
/* dword 0 expected value = 0x10002680 the RX buffer address */
/* dword 1 expected value = 0x80140000 */
/* Bits 15-0 is the next descriptor pointer */
/* Bits 28-16 is the number of bytes stored in the data buffer */
/* Bits 31-29 indicates buffer status */
/* dword 2 expected value = 0xxxxxxx00 */
/* Bits 7-0 indicates HDLC channel number (should match TDQ entry channel) */
/* Bits 31-8 indicates the timestamp (varies) */
rdscr_idx = rdq_entry & 0x0000FFFF;
rd_dword(rdscr_base_addr + 16*rdscr_idx, rdscr_dword0);
rd_dword(rdscr_base_addr + 16*rdscr_idx + 4, rdscr_dword1);
rd_dword(rdscr_base_addr + 16*rdscr_idx + 8, rdscr_dword2);

/* Check the data in the RX buffer */
/* 16 bytes of data + 4-byte CRC */
/* Expected values = 	0x01234567 */
/* 			0x89ABCDEF */
/* 			0x02468ACE */
/* 			0x13579BDF */
/* 			0x05127B09 (4-byte CRC) */
byte_count = (rdscr_dword1 > > 16) & 0x00001FFF;
for (addr = rdscr_dword0, addr < rdscr_dword0 + byte_count; addr = addr + 4)
rd_dword(addr, data);

/* Advance the RX done-queue read pointer */
if (rd_ptr == rdq_end_idx)
rd_ptr = 0;
else
rd_ptr = rd_ptr + 1;
write_reg(RDQRP, rd_ptr);
}

針對高速使用的其他優(yōu)化

許多變量都是逐個應(yīng)用程序優(yōu)化的,并且可以預(yù)期一定程度的性能調(diào)整。以下選項可能會有所幫助,具體取決于手頭應(yīng)用程序的詳細(xì)信息

  1. 端口時鐘反轉(zhuǎn)

    在高端口時鐘頻率的應(yīng)用中,端口數(shù)據(jù)變化沿和端口時鐘采樣邊沿之間的偏斜可能成為滿足DS31256數(shù)據(jù)時鐘設(shè)置要求的問題。反轉(zhuǎn)相應(yīng)的DS31256端口時鐘可以解決這種偏斜問題。通過在寄存器 TP[n]CR 中設(shè)置 TICE 位,可以逐端口反轉(zhuǎn) TX 端口時鐘。通過在寄存器RP[n]CR中設(shè)置RICE位,可以反轉(zhuǎn)RX端口時鐘。

    /* invert the receive clock */
    for(port = 0; port < 16; port++)
    {
    	RPnVal = read_reg(RP0CR + 4*port);
    	RpnVal = RpnVal | 1;
    }
    /* Transmit clock can be inverted in the same manner using the TPnCR register */
    
  2. DS31256 TX/RX 隊列緩存

    DS31256包含內(nèi)部高速緩存存儲器,可用于突發(fā)讀/寫多個DMA隊列條目,從而減少DS31256用于執(zhí)行這些DMA操作的PCI總線帶寬量。重置后將禁用這些緩存。用于啟用和配置這些內(nèi)部緩存存儲器的寄存器如下:

    • TDMAQ - TX DMA 隊列控制
    • TDQFFT - TX DMA 完成隊列 FIFO 刷新計時器
    • RDMAQ - RX DMA 隊列控制
    • RDQFFT - RX DMA 完成隊列 FIFO 刷新計時器

    TDMAQ寄存器用于啟用和刷新DS31256 TX待處理隊列緩存和TX完成隊列緩存。RDMAQ 寄存器用于啟用和刷新 RX 空閑隊列緩存和 RX 完成隊列緩存。寄存器 TDQFFT 和 RDQFFT 用于控制 TX 完成隊列緩存和 RX 完成隊列緩存中的條目刷新到主機內(nèi)存中各自緩存的頻率。

    TX/RX 完成隊列 FIFO 刷新計時器控制 TX/RX 完成隊列條目在寫出到主機內(nèi)存中的相應(yīng)隊列之前在緩存中等待的最長時間。為了最大限度地提高從內(nèi)部緩存到主機內(nèi)存的突發(fā)完成隊列條目的效率,應(yīng)將刷新計時器值設(shè)置為足夠大的值,以便在正常操作下,觸發(fā)緩存寫入主機內(nèi)存的將是緩存高水位線,而不是刷新計時器超時。在數(shù)據(jù)包速率較低的應(yīng)用程序中,太大的刷新計時器值可能會導(dǎo)致將完成隊列條目放入緩存與將其寫出到主機內(nèi)存中的隊列之間的延遲增加。因此,必須根據(jù)應(yīng)用要求選擇先進先出沖洗定時器的最佳值。

    /* Slow flushes */
    write_reg(CHAT_REG_DMA_RDQFFT, 0x1000);
    write_reg(CHAT_REG_DMA_TDQFFT, 0x1000);
    

    請參考DS31256數(shù)據(jù)資料,詳細(xì)了解如何配置這些寄存器。

  3. DMA 隊列的中斷驅(qū)動主機服務(wù)

    如果DS31256工作在橋接模式,則PCI總線在DS31256 DMA傳輸和DS31256內(nèi)部寄存器訪問之間共享。如果主機處理器使用輪詢方案為DS31256的DMA隊列提供服務(wù),則輪詢速率會對DS31256的最大吞吐能力產(chǎn)生負(fù)面影響,因為寄存器輪詢占用了一定比例的PCI總線帶寬。輪詢還會給處理器帶來不必要的負(fù)擔(dān),因為它會產(chǎn)生大量開銷。為了盡量減少用于DS31256寄存器訪問的PCI總線帶寬百分比,可以實現(xiàn)中斷驅(qū)動的DMA隊列服務(wù)方案。通過在ISDMA寄存器中設(shè)置適當(dāng)?shù)奈唬梢允褂酶鞣NDS31256 DMA隊列訪問事件在DS31256 LINT和PINTA引腳上產(chǎn)生硬件中斷。請參考DS31256數(shù)據(jù)資料了解更多詳情。
    進一步的優(yōu)化是能夠?qū)S31256進行編程,使其僅在發(fā)生多個TX/RX完成隊列寫入事件后,而不是僅在單個寫入事件之后設(shè)置SDMA寄存器中的TDQW/RDQW位。此功能可用于降低 TX/RX 完成隊列寫入中斷的頻率,并增加在檢測到中斷時準(zhǔn)備處理的 TX/RX 完成隊列條目的數(shù)量。因此,處理 TX/RX 完成隊列條目變得更加高效。在發(fā)送端,此功能由TDMAQ寄存器中的位域TDQT[2:0]控制。在接收端,此功能由位字段 RDQT[2:0] 和 RDMAQ 寄存器控制。請參考DS31256數(shù)據(jù)資料了解更多詳情。

    /* Interrupt driven code is almost certainly required at high speeds. */
    /* Turn on interrupts for RLBR */
    write_reg(CHAT_REG_GEN_ISDMA, read_reg(CHAT_REG_GEN_ISDMA) |
    CHAT_BIT_GEN_SDMAISDMA_RLBR);
    
  4. TX/RX 先進先出大小和水印

    最佳 TX/RX FIFO 塊分配和水印設(shè)置因應(yīng)用要求而異。以下準(zhǔn)則可用作起點:

    • 對于所有 HDLC 通道具有大致均勻吞吐量要求的應(yīng)用,請在通道之間均勻分配 FIFO 模塊。
    • 對于 HDLC 通道沒有統(tǒng)一吞吐量要求的應(yīng)用,請使用基于吞吐量的加權(quán)方案在通道之間劃分 FIFO 塊。對于具有較高吞吐量要求的通道,應(yīng)分配更多相對于具有較低吞吐量要求的通道的 FIFO 塊。
    • 具有大致相同吞吐量要求的所有 HDLC 通道都應(yīng)將其低傳輸水位線設(shè)置為相同的值。同樣,它們的接收高水位線應(yīng)設(shè)置為相同的值。
    • 將 TX FIFO 低水位線設(shè)置為 25%。根據(jù)需要增加,直到達到可接受的 TX 下溢率。

    選擇 TX FIFO 低水位線值的目的是在通道 TX FIFO 數(shù)據(jù)請求到服務(wù)延遲和高效數(shù)據(jù)傳輸?shù)?TX FIFO 之間找到可接受的平衡。低水位線值可最大限度地提高數(shù)據(jù)傳輸效率,因為 TX FIFO 能夠在提供服務(wù)時接受更多數(shù)據(jù)。TX FIFO在維修時可以接受的數(shù)據(jù)越多,DS31256就越能有效地將新數(shù)據(jù)從主機存儲器DM傳輸?shù)絋X FIFO。相反,低水位線的高值可最大程度地減少傳輸下溢的可能性。TX FIFO 請求更多數(shù)據(jù)時的數(shù)據(jù)量越大,TX FIFO 在下溢之前等待服務(wù)的時間就越長。

    將 RX FIFO 高水位線設(shè)置為 75%。根據(jù)需要減少,直到達到可接受的 RX 溢出率。

    選擇 RX FIFO 高水位線的目標(biāo)是在 RX FIFO 數(shù)據(jù)請求到服務(wù)延遲和高效數(shù)據(jù)傳輸?shù)?TX FIFO 之間找到可接受的平衡。高水位線的高值可最大限度地提高數(shù)據(jù)傳輸效率,因為 RX FIFO 在提供服務(wù)時將包含更多數(shù)據(jù)。RX FIFO包含的數(shù)據(jù)越多,DS31256將數(shù)據(jù)DMA輸出到主機存儲器的效率就越高。相反,高水位線的低值可將接收溢出的可能性降至最低。RX FIFO 請求清空時的空白空間越多,RX FIFO 在溢出之前等待維修的時間就越長。

  5. DMA 突發(fā)長度

    DS31256的默認(rèn)DMA突發(fā)長度為32個雙字。在支持更長突發(fā)的系統(tǒng)中,DS31256 DMA數(shù)據(jù)傳輸效率可以通過將其最大DMA突發(fā)長度增加到64個dwords、128個dwords或256個dwords來提高。這是通過DS31256 MC寄存器中的DS1 TX/RX DMA節(jié)流參數(shù)、位字段TDT[0:1]和RDT[0:31256]實現(xiàn)的。增加DS31256的最大DMA突發(fā)長度的結(jié)果是,DS31256 DMA事務(wù)的待處理延遲以及與DS31256共享PCI總線的其他器件的待處理事務(wù)可能會增加延遲。
    DS31256另外兩個可用于提高DMA突發(fā)效率的參數(shù)是PCI總線高速緩存線路大小和PCI總線延遲定時器。這些參數(shù)中的每一個都控制DS31256如何執(zhí)行PCI總線事務(wù)。
    高速緩存行大小參數(shù)寄存器 PLTH0[7:0] 應(yīng)設(shè)置為與系統(tǒng)內(nèi)存控制器的高速緩存行大小匹配。當(dāng)DS31256嘗試執(zhí)行超過高速緩存行大小的突發(fā)讀取時,它將發(fā)出存儲器讀取多個命令而不是存儲器讀取命令,以通知存儲器系統(tǒng)正在啟動多高速緩存行讀取。如果內(nèi)存系統(tǒng)能夠提前讀取一個或多個附加高速緩存行,則當(dāng)讀取的數(shù)據(jù)總量超過單個高速緩存行時,這可能會導(dǎo)致更高效的數(shù)據(jù)傳輸。
    延遲定時器參數(shù)寄存器PLTH0[15:8]控制DS31256在PCI總線仲裁器解除DS31256的PGNT輸入信號后放棄對總線的控制之前的最短時間長度。延遲定時器值越大,潛在的PCI事務(wù)突發(fā)長度越長,從而可以提高DS31256數(shù)據(jù)傳輸?shù)男省H欢?,由于DS31256放棄PCI總線的速度較慢,PCI總線上其他器件的潛在授權(quán)延遲會增加。請參考DS31256數(shù)據(jù)資料,了解這些特性的更多詳細(xì)信息。

  6. TX/RX FIFO HDLC 信道仲裁

    重置后,TX/RX FIFO HDLC 通道仲裁方案設(shè)置為輪循機制。對于低通道數(shù)應(yīng)用程序,可以通過使用基于優(yōu)先級的仲裁方案而不是輪循機制方案來減少通道服務(wù)延遲。TX/RX FIFO HDLC 信道仲裁方案通過 MC 寄存器中的 TFPC[1:0] 和 RFPC[1:0] 位字段進行選擇。請參考DS31256數(shù)據(jù)資料了解更多詳情。

  7. 雜項提示

    為了幫助早期代碼開發(fā),請編寫一個函數(shù)來回收數(shù)據(jù)包,然后使用它設(shè)置一個長測試循環(huán)。這將測試所有循環(huán)隊列,因為它們圍繞著一個共同的困難源,并確保代碼中沒有內(nèi)存泄漏。

結(jié)論

本應(yīng)用筆記介紹了如何在橋接模式下為DS3配置單個T31256端口的非溝道工作。編碼示例描述了如何對DS31256進行編程(配置)并詳細(xì)(逐步)發(fā)送/接收數(shù)據(jù)包。本應(yīng)用筆記列出了DS31256高速使用的一些有用優(yōu)化。

審核編輯:郭婷

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • 調(diào)制解調(diào)器

    關(guān)注

    3

    文章

    838

    瀏覽量

    38703
  • PCI
    PCI
    +關(guān)注

    關(guān)注

    4

    文章

    655

    瀏覽量

    130057
  • 總線
    +關(guān)注

    關(guān)注

    10

    文章

    2848

    瀏覽量

    87839
收藏 人收藏

    評論

    相關(guān)推薦

    DS31256,pdf,datasheet (256-Cha

    streams or two T3 data streams. Each of the 16 physical ports can handle one, two, or four T1 or E1 data streams.
    發(fā)表于 04-21 23:49 ?18次下載

    DS3150 業(yè)內(nèi)首款單端口T3/E3 LIU,集成了抖動衰

    DS3150 業(yè)內(nèi)首款單端口T3/E3 LIU,集成了抖動衰減器 DS3150可以實現(xiàn)在物理層與DS3
    發(fā)表于 09-19 16:20 ?1332次閱讀
    <b class='flag-5'>DS</b>3150 業(yè)內(nèi)首款單<b class='flag-5'>端口</b><b class='flag-5'>T3</b>/<b class='flag-5'>E3</b> LIU,集成了抖動衰

    Examples of DS31256 Applicatio

    Abstract: App Note 3345 provides application examples for the DS31256 HDLC Controller.
    發(fā)表于 04-18 11:25 ?744次閱讀
    Examples of <b class='flag-5'>DS31256</b> Applicatio

    DS31256 Unchannelized T3/E3/HS

    Abstract: This application note provides an example of how to configure a single T3/E3/HSSI/VDSL
    發(fā)表于 04-20 08:51 ?981次閱讀

    DS31256的初始步驟

    摘要:DS31256 Envoy HDLC控制器在發(fā)送數(shù)據(jù)包之前的初始順序。 概述按照設(shè)計,DS31256上電以后不會控制PCI總線。所有的物理端口(
    發(fā)表于 04-20 09:02 ?952次閱讀

    DS31256 and T1/E1 Interface

    Abstract: This application note discusses how to connect the DS31256 HDLC Controller to the DS
    發(fā)表于 04-20 09:26 ?1546次閱讀
    <b class='flag-5'>DS31256</b> and <b class='flag-5'>T</b>1/<b class='flag-5'>E</b>1 Interface

    DS31256 HDLC控制器的配置步驟—模式

    DS31256 HDLC控制器的配置步驟—模式 本應(yīng)用筆記提供了怎樣配置
    發(fā)表于 04-21 14:59 ?1499次閱讀
    <b class='flag-5'>DS31256</b> HDLC控制器的<b class='flag-5'>配置</b>步驟—<b class='flag-5'>橋</b><b class='flag-5'>接</b><b class='flag-5'>模式</b>

    DS31256 -256通道、高吞吐率HDLC控制器

    DS31256 -256通道、高吞吐率HDLC控制器 概述 DS31256是一款256通道高層數(shù)據(jù)鏈路控制器(HDLC),
    發(fā)表于 04-21 23:17 ?1353次閱讀
    <b class='flag-5'>DS31256</b> -256<b class='flag-5'>通道</b>、高吞吐率HDLC控制器

    T3(E3)保護電路及解決方案

    T3(E3)保護電路及解決方案 接口
    發(fā)表于 11-20 09:23 ?1933次閱讀
    <b class='flag-5'>T3</b>(<b class='flag-5'>E3</b>)保護電路及解決方案

    如何利用DS31256 HDLC控制器實現(xiàn)間隔時鐘應(yīng)用

    DS31256有16個物理端口(16 Tx和16 Rx)或鏈路,可配置為信道信道。
    的頭像 發(fā)表于 01-13 10:25 ?784次閱讀
    如何利用<b class='flag-5'>DS31256</b> HDLC控制器實現(xiàn)間隔時鐘應(yīng)用

    DS31256 接口 - 電信

    電子發(fā)燒友網(wǎng)為你提供Maxim(Maxim)DS31256相關(guān)產(chǎn)品參數(shù)、數(shù)據(jù)手冊,更有DS31256的引腳圖、接線圖、封裝手冊、中文資料、英文資料,DS31256真值表,DS31256
    發(fā)表于 01-14 19:46
    <b class='flag-5'>DS31256</b> 接口 - 電信

    DS31256閉合時鐘應(yīng)用

    DS16有16個物理端口(16 Tx和31256 Rx)或鏈路,可配置為信道信道
    的頭像 發(fā)表于 02-13 15:43 ?615次閱讀
    <b class='flag-5'>DS31256</b>閉合時鐘應(yīng)用

    T3E3網(wǎng)絡(luò)接口布局指南

    本應(yīng)用筆記是關(guān)于如何布局Maxim T3/E3線路接口單元(LIU)網(wǎng)絡(luò)接口的指南。該指南以DS315x產(chǎn)品為例。本應(yīng)用筆記也適用于其他Maxim
    的頭像 發(fā)表于 02-22 09:41 ?2047次閱讀
    <b class='flag-5'>T3</b>和<b class='flag-5'>E3</b>網(wǎng)絡(luò)接口布局指南

    HFTA-09.0: T3/E3/STS-1 光纖擴展

    本應(yīng)用筆記將介紹設(shè)計T3/E3/STS-1光纖到銅介質(zhì)轉(zhuǎn)換器所需的條件。這種設(shè)備將獲取銅信號并將其轉(zhuǎn)換為光信號,通過光纖鏈路傳輸。一對轉(zhuǎn)換器將透明地將T3/E3/STS-1信號擴展到其
    的頭像 發(fā)表于 03-03 15:34 ?816次閱讀
    HFTA-09.0: <b class='flag-5'>T3</b>/<b class='flag-5'>E3</b>/STS-1 光纖擴展

    HFTA-09.0: T3/E3/STS-1光纖擴展

    通常,T3/E3/STS-1 信號在短距離內(nèi)傳輸,但某些應(yīng)用需要更長的距離。T3/E3/STS-1 光纖到銅轉(zhuǎn)換器接收銅纜信號并將其轉(zhuǎn)換為光信號,通過光纖鏈路傳輸。一對轉(zhuǎn)換器將
    的頭像 發(fā)表于 06-10 15:28 ?751次閱讀
    HFTA-09.0: <b class='flag-5'>T3</b>/<b class='flag-5'>E3</b>/STS-1光纖擴展