STM32F1 ETHERNET

Started by tha, February 11, 2021, 08:40:30 AM

Previous topic - Next topic

tha

MII/RMII transmit bit order

แต่ละ nibble (4 บิต) จาก the MII ถูกส่งบน the RMII a dibit (2 บิต) ในแต่ละครั้งโดยลำดับของ dibit transmission ถูกแสดงใน Figure 339. Lower order bits (D1 and D0) ถูกส่งก่อนตามด้วย higher order bits (D2 and D3).




tha

29.5.3 MAC frame reception

The MAC รับ frames ใส่ลงใน the Rx FIFO. The status (ระดับการเติม) ของ FIFO นี้ถูกแสดงให้เห็นไปยัง the DMA ทันทีที่มันข้าม the configured receive threshold (RTC ใน the ETH_DMAOMR register) ดังนั้น the DMA สามารถเริ่มต้น pre-configured burst transfers ไปยัง the AHB interface.

ใน the default Cut-through mode, เมื่อ 64 bytes (กำหนดค่าด้วย the RTC bits ใน the ETH_DMAOMR register) หรือ a full packet of data ถูกรับลงใน the FIFO, the data ถูก popped out และ the DMA ถูกแจ้งให้ทราบการมีให้ใช้ของมัน. ทันทีที่ the DMA เริ่มต้น the transfer ไปยัง the AHB interface, the data ส่งถ่ายอย่างต่อเนื่องจาก the FIFO จนกระทั่ง a complete packet ถูกส่งถ่ายแล้ว. เมื่อ completion of the EOF frame ส่งถ่าย, the status word ถูก popped out และส่งไปยัง the DMA controller.

ใน Rx FIFO Store-and-forward mode (กำหนดค่าโดย the RSF bit ใน the ETH_DMAOMR register), a frame ถูกอ่านเฉพาะหลังจากถูกเขียนลงใน the Receive FIFO เสร็จสมบูรณ์แล้ว. ในโหมดนี้, all error frames ถูก dropped (ถ้า the core ถูกกำหนดค่าให้ทำเช่นนั้น) ดังนั้นเฉพาะ valid frames ถูกอ่านและส่งต่อไปยัง the application. ใน Cut-through mode, some error frames
ไม่ถูก dropped, เพราะว่า the error status ถูกรับที่ the end of the frame, ตามเวลาจุดสตาร์ทของเฟรมนั้นได้ถูกอ่านของ the FIFO แล้ว

A receive operation ถูกเริ่มต้นเมื่อ the MAC ตรวจพบ an SFD บน the MII. The core ปอก the preamble and SFD ก่อนดำเนินการต่อเพื่อประมวลผล the frame. The header fields ถูกเช็คสำหรับ the filtering และ the FCS field ถูกใช้เพื่อตรวจสอบ the CRC สำหรับ the frame. The frame ถูก dropped ใน the core ถ้ามันล้มเหลว the address filter

tha

Receive protocol

The received frame preamble and SFD ถูกปอก. ทันทีที่ the SFD ถูกตรวจพบ, the MAC สตาร์ทการส่ง the Ethernet frame data ไปยัง the receive FIFO, เริ่มต้นด้วย the first byte ตามด้วย the SFD (destination address). ถ้า IEEE 1588 time stamping ถูกเปิดการใช้งาน, a snapshot of the system time ถูกจับเมื่อ any frame's SFD ถูกตรวจพบบน the MII. เว้นแต่ the MAC กรองออกและดร็อป the frame, time stamp นี้จะถูกส่งต่อไปยัง the application.

ถ้า the received frame length/type field น้อยกว่า 0x600 และถ้า the MAC ถูกโปรแกรมสำหรับ the auto CRC/ทางเลือกการปอก pad, the MAC ส่ง the data ของ the frame ไปยัง RxFIFO สูงถึง the count ที่ระบุใน the length/type field, จากนั้นสตาร์ทการดร็อป bytes (รวมทั้ง the FCS field). ถ้า the Length/Type field มากกว่าหรือเท่ากับ 0x600, the MAC ส่ง all received Ethernet frame data ไปยัง Rx FIFO, โดยไม่คำนึงถึงค่าบน the programmed auto-CRC strip option. The MAC watchdog timer ถูกเปิดการใช้งานโดยเริ่มต้น, นั่นคือ, frames ที่สูงกว่า 2048 bytes (DA + SA + LT + Data + pad + FCS) จะถูกตัดออก. คุณลักษณะนี้สามารถถูกปิดการใช้งานโดยการโปรแกรม the watchdog disable (WD) bit ใน the MAC configuration register. อย่างไรก็ตาม, ถึงแม้ว่า the watchdog timer ถูกปิดการใช้งาน, frames ที่มีขนาดมากกว่า 16 KB จะถูกตัดออกและ a watchdog timeout status ถูกให้.


tha

Receive CRC: automatic CRC and pad stripping

The MAC เช็คสำหรับ any CRC error ใน the receiving frame. มันคำนวณ the 32-bit CRC สำหรับ the received frame ที่รวมถึง the Destination address field ผ่านทาง the FCS field. การเข้ารหัสถูกกำหนดโดยพหุนามต่อไปนี้

         

โดยไม่คำนึงถึง the auto-pad/CRC strip, the MAC รับ the entire frame เพื่อคำนวณ the CRC เช็คสำหรับ the received frame.

tha

Receive checksum offload

ทั้ง IPv4 and IPv6 frames ใน the received Ethernet frames ถูกตรวจพบและประมวลผลเพือข้อมูลที่สมบูรณ์. คุณสามารถเปิดการใช้งาน the receive checksum offload โดยการเซ็ต the IPCO bit ใน the ETH_MACCR register. The MAC receiver วินิจฉัย IPv4 or IPv6 frames โดยการเช็คสำหรับค่า 0x0800 หรือ 0x86DD, ตามลำดับ, ใน the received Ethernet frame Type field. การวินิจฉัยนี้ใช้กับ VLAN-tagged frames เช่นกัน. The receive checksum offload คำนวณ IPv4 header checksums และเช็คว่าตรงกับ the received IPv4 header checksums. The IP Header Error bit ถูกเซ็ตสำหรับความไม่ตรงกันใดๆระหว่าง the indicated payload type (Ethernet Type field) และ the IP header version, หรือเมื่อ the received frame ไม่มี bytes เพียงพอ, ตามที่แสดงให้เห็นโดย the IPv4 header's Length field (หรือเมื่อน้อยกว่า 20 bytes มีให้ใช้ใน an IPv4 or IPv6 header). The receive checksum offload ยังวินิจฉัย a TCP, UDP or ICMP payload ใน the received IP datagrams (IPv4 or IPv6) อีกด้วยและคำนวณ the checksum ของ payloads ดังกล่าวอย่างเหมาะสม, ตามที่กำหนดใน the TCP, UDP or ICMP specifications. มันรวม the TCP/UDP/ICMPv6 pseudo-header bytes สำหรับ checksum calculation และเช็คว่า the received checksum field ตรงกับ the calculated value. ผลของการทำงานนี้ถูกให้เป็น a Payload Checksum Error bit ใน the receive status word. status bit นี้ถูกเซ็ตอีกด้วยถ้าความยาวของ the TCP, UDP or ICMP payload ไม่ตรงกับ the expected payload length ที่ให้ใน the IP header.ตามที่กล่าวไว้ใน TCP/UDP/ICMP checksum, the receive checksum offload ข้ามผ่าน the payload of fragmented IP datagrams, IP datagrams ที่มี security features, IPv6 routing headers, และ payloads อื่นที่ไม่ใช่ TCP, UDP or ICMP. ข้อมูลนี้  (ไม่ว่า the checksum ถูกข้ามผ่านหรือไม่ก็ตาม) ถูกให้ใน the receive status, ตามที่อธิบายใน the RDES0: Receive descriptor Word0 section. ในการกำหนดค่านี้, the core ไม่ต่อท้าย any payload checksum bytes ไปยัง the received Ethernet frames.

ตามที่กล่าวไว้ใน RDES0: Receive descriptor Word0, ความหมายของ certain register bits เปลี่ยนแปลงดังแสดงใน Table 214.


tha

Receive frame controller

ถ้า the RA bit ถูกรีเซ็ตใน the MAC CSR frame filter register, the MAC ดำเนินการ frame filtering ขึ้นอยู่กับ the destination/source address (the application ยังคงต้องการเพื่อดำเนินการระดับอื่นของการกรองถ้ามันตัดสินใจไม่รับ any bad frames อย่าง runt, CRC error frames, etc.). บนการตรวจพบ a filter-fail, the frame ถูกดร็อปและไม่ส่งถ่ายไปยัง the application. เมื่อ the
filtering parameters ถูกเปลี่ยนแบบไดนามิก, และในกรณีของ (DA-SA) filter-fail, ส่วนที่เหลือของ the frame ถูกดร็อปและ the Rx Status Word ถูกอัปเดตทันที (ที่มี zero frame length, CRC error and Runt Error bits เซ็ต), แสดงให้เห็น the filter fail. ใน Ethernet power down mode, all received frames ถูกดร็อป, และไม่ถูกส่งต่อไปยัง the application.

tha

Receive flow control

The MAC ตรวจพบ the receiving Pause frame และหยุด the frame transmission เป็นเวลา the delay ที่ระบุภายใน the received Pause frame (เฉพาะใน Full-duplex mode). The Pause frame detection function สามารถถูก enabled หรือ disabled ด้วย the RFCE bit ใน ETH_MACFCR. ทันทีที่ receive flow control ถูก enabled แล้ว, the received frame destination address เริ่มต้นถูกมอนิเตอร์สำหรับการตรงกันใดๆกับ the multicast address ของ the control frame (0x0180 C200 0001). ถ้าการตรงกันถูกตรวจพบ (the destination address of the received frame ตรงกับ the reserved control frame destination address), the MAC จากนั้นตัดสินใจว่าจะส่งถ่ายหรือไม่ส่งถ่าย the received control frame ไปยัง the application, ขึ้นอยู่กับ the level of the PCF bit in ETH_MACFFR.

The MAC ยังถอดรหัส the type, opcode, and Pause Timer fields of the receiving control frame. ถ้า the byte count of the status แสดงให้เห็น 64 bytes, และถ้าไม่มี CRC error, the MAC transmitter หยุด the transmission of any data frame เป็นเวลาในช่วงเวลาของ the decoded Pause time value, คูณด้วย the slot time (64 byte times สำหรับทั้ง 10/100 Mbit/s modes). ในขณะเดียวกัน, ถ้า another Pause frame ถูกตรวจพบที่มี a zero Pause time value, the MAC รีเซ็ต the Pause time และจัดการ new pause request นี้.

ถ้า the received control frame ไม่ตรงกับ the type field (0x8808), the opcode (0x00001), หรือ the byte length (64 bytes), หรือถ้ามี a CRC error, the MAC ไม่สร้าง a Pause.

ในกรณีของ a pause frame ที่มี a multicast destination address, the MAC กรอง the frame ขึ้นอยู่กับ the address match.

สำหรับ a pause frame ที่มี a unicast destination address, the MAC filtering ขึ้นอยู่กับว่า the DA ตรงกับ the contents of the MAC address 0 register และหรือว่า the UPDF bit ใน ETH_MACFCR ถูกเซ็ต (การตรวจพบ a pause frame แม้จะมี a unicast destination address). The PCF register bits (bits [7:6] in ETH_MACFFR) ควบคุมการกรองสำหรับ control frames
นอกเหนือจาก address filtering.

tha

Receive operation multiframe handling

เนื่องจาก the status มีให้ใช้ทันทีติดตาม the data, the FIFO มีสามารถของการเก็บ any number of frames ลงในมัน, ตราบเท่าที่มันไม่เต็ม.