mirror of
https://github.com/PDP-10/its.git
synced 2026-03-20 08:28:43 +00:00
WIP: Feeds packets into IP, and gets back to ETHTXI
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
;FIXME The big one - interrupts? Compare with CHAOS...
|
||||
|
||||
;;; Generic Ethernet support
|
||||
|
||||
%NE32==37777777777
|
||||
@@ -88,11 +90,6 @@ ETHATS: 0 ;Number of entries in ARP table
|
||||
|
||||
BBLK
|
||||
|
||||
IPOGO: BUG INFO,[ipogo]
|
||||
POPJ P,
|
||||
IPKSNE: BUG INFO,[ipksne]
|
||||
POPJ P,
|
||||
|
||||
;Process a received packet.
|
||||
;R is buffer. Length in bytes is I. May clobber A-I, R.
|
||||
;
|
||||
@@ -104,7 +101,7 @@ ETHRX: MOVEI TT,ETHHBF ;Unpack Ethernet header into ETHHBF
|
||||
ADDI R,%NEH"WORDS ;R points to data
|
||||
|
||||
LDB A,[%NEH"TYPE+ETHHBF]
|
||||
BUG INFO,[etype=],OCT,A
|
||||
;BUG INFO,[etype=],OCT,A
|
||||
CAIN A,%NETYP"IP
|
||||
JRST ETHRXI
|
||||
CAIN A,%NETYP"ARP
|
||||
@@ -114,7 +111,7 @@ ETHRX: MOVEI TT,ETHHBF ;Unpack Ethernet header into ETHHBF
|
||||
|
||||
;Process an ARP packet.
|
||||
;
|
||||
ETHRXA: BUG INFO,[ARP length ],OCT,I
|
||||
ETHRXA: ;BUG INFO,[ARP length ],OCT,I
|
||||
CAIGE I,%NEAH"LENGTH ;Check size first
|
||||
JRST ETHRAS
|
||||
|
||||
@@ -138,13 +135,13 @@ ETHRXA: BUG INFO,[ARP length ],OCT,I
|
||||
LSH A,16.
|
||||
LDB B,[%NEAH"SPA1+ETHABF]
|
||||
IOR A,B
|
||||
BUG INFO,[ARP source addr ],OCT,A
|
||||
;BUG INFO,[ARP source addr ],OCT,A
|
||||
|
||||
MOVE E,ETHATS ;Is the IP address in the table already?
|
||||
SOS E
|
||||
ETHRX1: JUMPL E,ETHRX2 ;Any more entries to check?
|
||||
LDB B,[%NEAT"PA+ETHAT(E)]
|
||||
BUG INFO,[ARP table entry ],OCT,E,[ of ],OCT,ETHATS,[ is ],OCT,B
|
||||
;BUG INFO,[ARP table entry ],OCT,E,[ of ],OCT,ETHATS,[ is ],OCT,B
|
||||
CAMN A,B ;Match?
|
||||
JRST ETHRX3 ; Yes - update it
|
||||
SOJA E,ETHRX1 ;Prev entry
|
||||
@@ -165,7 +162,7 @@ ETHRX3: DPB A,[%NEAT"PA+ETHAT(E)] ;Store IP address
|
||||
BUG INFO,[Set ARP table entry ],OCT,E,[ to ip ],OCT,A,[ mac ],OCT,C,[ ],OCT,D
|
||||
|
||||
LDB E,[%NEAH"OP+ETHABF] ;Get op
|
||||
BUG INFO,[ARP op ],OCT,E
|
||||
;BUG INFO,[ARP op ],OCT,E
|
||||
CAIE E,%NEAOP"REQ ;Is this a request?
|
||||
POPJ P, ;No - nothing more to do
|
||||
|
||||
@@ -173,7 +170,7 @@ ETHRX3: DPB A,[%NEAT"PA+ETHAT(E)] ;Store IP address
|
||||
CAME B,[ETHUS] ;Is it our address?
|
||||
POPJ P, ;No - nothing more to do
|
||||
|
||||
BUG INFO,[ARP reply]
|
||||
;BUG INFO,[ARP reply]
|
||||
MOVEI E,%NEAOP"REPLY ;Construct reply packet
|
||||
DPB E,[%NEAH"OP+ETHABF]
|
||||
DPB A,[%NEAH"TPA+ETHABF] ;Set sender PA as target PA
|
||||
@@ -205,9 +202,47 @@ ETHRAP: BUG INFO,[ARP wrong protocol ],OCT,B
|
||||
POPJ P,
|
||||
|
||||
;Process an IPv4 packet.
|
||||
;May clobber A-I, R.
|
||||
;
|
||||
ETHRXI:
|
||||
BUG INFO,[IP]
|
||||
ETHRXI: PUSH P,Q ;IP can clobber all of these...
|
||||
PUSH P,J
|
||||
PUSH P,R
|
||||
PUSH P,W
|
||||
PUSH P,H
|
||||
|
||||
MOVE A,I ;Compute number of words
|
||||
AOS A
|
||||
LSH A,-2
|
||||
MOVE C,A
|
||||
;BUG INFO,[IP ipgipt A=],OCT,A
|
||||
PUSHJ P,IPGIPT ;Get IP buffer -> A=datagram struct
|
||||
JRST ETHRX5 ; No buffers
|
||||
|
||||
MOVE B,PK.BUF(A) ;IPGIPT does return this, but in BLKI form...
|
||||
BUG INFO,[IP rx allocated A=],OCT,A,[ B=],OCT,B
|
||||
HRL B,R
|
||||
ADDI C,-1(B)
|
||||
BLTUB B,(C) ;Copy packet
|
||||
|
||||
MOVE B,C ;Words in datagram
|
||||
SETZM C ;Offset to header
|
||||
SETZM J ;Host table index of address (not used)
|
||||
PUSHJ P,IPRDGM
|
||||
|
||||
;BUG INFO,[IP rdgm done]
|
||||
|
||||
ETHRX5: POP P,H
|
||||
POP P,W
|
||||
POP P,R
|
||||
POP P,J
|
||||
POP P,Q
|
||||
POPJ P,
|
||||
|
||||
;Send an IP packet (like IPKSNC for CHAOS).
|
||||
;A contains datagram struct.
|
||||
;
|
||||
ETHTXI: MOVE B,PK.DST(A)
|
||||
BUG INFO,[ethtxi A=],OCT,A,[ dest=],OCT,B
|
||||
POPJ P,
|
||||
|
||||
;Send an Ethernet packet (if possible).
|
||||
@@ -218,7 +253,7 @@ ETHRXI:
|
||||
ETHTX: BUG INFO,[ethtx ptr ],OCT,R,[ len ],OCT,I
|
||||
PUSHJ P,UNAFF ;Find a free transmit buffer
|
||||
POPJ P, ;None left. Give up.
|
||||
BUG INFO,[ethtx buf ],OCT,B,[ desc ],OCT,D,[ len ],OCT,I
|
||||
;BUG INFO,[ethtx buf ],OCT,B,[ desc ],OCT,D,[ len ],OCT,I
|
||||
|
||||
MOVE TT,B ;Convert header
|
||||
HRLI TT,ETHHBF
|
||||
@@ -232,17 +267,18 @@ ETHTX: BUG INFO,[ethtx ptr ],OCT,R,[ len ],OCT,I
|
||||
LSH A,-2
|
||||
ADD A,B
|
||||
MOVE C,TT ;XXX
|
||||
BUG INFO,[ethtx data bltbu tt ],OCT,C,[ a ],OCT,A
|
||||
;BUG INFO,[ethtx data bltbu tt ],OCT,C,[ a ],OCT,A
|
||||
BLTBU TT,(A)
|
||||
|
||||
ADDI I,%NEH"LENGTH-%NEH"PAD ;Add length of header
|
||||
BUG INFO,[ethtx end desc ],OCT,D,[ len ],OCT,I
|
||||
;BUG INFO,[ethtx end desc ],OCT,D,[ len ],OCT,I
|
||||
JRST UNATX ;Transmit it
|
||||
|
||||
;Check whether the interface is able to send a packet.
|
||||
;Skip-return if it is.
|
||||
;
|
||||
ETHCTS:
|
||||
BUG INFO,[ethcts]
|
||||
;FIXME check if we have an ARP entry, and if not, send a request
|
||||
AOS (P)
|
||||
POPJ P,
|
||||
@@ -262,6 +298,8 @@ EBLK
|
||||
;address and the two Unibus addresses. We could then
|
||||
;allocate on the fly while setting up the rings.
|
||||
;FIXME The setup stuff might also be cleaner with byte ptrs as above.
|
||||
;FIXME Or should we just use IP buffers for all of this? They seem to be
|
||||
;half-page-aligned...
|
||||
|
||||
UNPAGS: BLOCK %UNNPG ;PDP-10 pages: 0,,addr
|
||||
UNPAGU: BLOCK %UNNPG ;Unibus pages: first-addr,,second-addr
|
||||
@@ -370,6 +408,7 @@ IFE 0,[
|
||||
MOVEI A,%UN0"DNI+%UNCMD"GETPCB ;Ack DNI as it's on after reset
|
||||
PUSHJ P,UNACMD ;We've really returned to the caller here
|
||||
|
||||
;FIXME put IP address in too, use in ARP above
|
||||
;Get the MAC address for ARP to use
|
||||
MOVE A,UNPAGS
|
||||
MOVSI TT,%UNAF"RDDPA
|
||||
@@ -385,10 +424,10 @@ IFE 0,[
|
||||
LSH A,16.
|
||||
ILDB B,TT
|
||||
IOR A,B
|
||||
BUG INFO,[my MAC 01 =],OCT,A
|
||||
;BUG INFO,[my MAC 01 =],OCT,A
|
||||
DPB A,[%NEAT"HA01+ETHME]
|
||||
ILDB A,TT
|
||||
BUG INFO,[my MAC 2 =],OCT,A
|
||||
;BUG INFO,[my MAC 2 =],OCT,A
|
||||
DPB A,[%NEAT"HA2+ETHME]
|
||||
|
||||
;Set up transmit and receive rings
|
||||
@@ -600,7 +639,7 @@ UNAFF1: HRRZ A,E ;Wrap index around
|
||||
|
||||
HLRZ D,UNTXRP(E) ;Descriptor
|
||||
MOVE A,1(D) ;Is this buffer free? (OWN=0)
|
||||
BUG INFO,[unaff checking slot ],OCT,E,[ status ],OCT,A
|
||||
;BUG INFO,[unaff checking slot ],OCT,E,[ status ],OCT,A
|
||||
TLNE A,%UNTD"OWN
|
||||
JRST [ AOBJN E,UNAFF1 ;Try the next one
|
||||
POPJ P,] ;No buffers free.
|
||||
@@ -609,7 +648,7 @@ UNAFF1: HRRZ A,E ;Wrap index around
|
||||
AOS UNTXRI ; (Doesn't matter if it wraps.)
|
||||
|
||||
HRRZ B,UNTXRP(E) ;Buffer
|
||||
BUG INFO,[unaff found free buffer ],OCT,E,[ desc ],OCT,D,[ buff ],OCT,B
|
||||
;BUG INFO,[unaff found free buffer ],OCT,E,[ desc ],OCT,D,[ buff ],OCT,B
|
||||
AOS (P) ;Skip return
|
||||
POPJ P,
|
||||
|
||||
@@ -617,7 +656,7 @@ UNAFF1: HRRZ A,E ;Wrap index around
|
||||
;Descriptor in D, data length in bytes in I.
|
||||
;Clobbers A.
|
||||
;
|
||||
UNATX: BUG INFO,[unatx desc ],OCT,D,[ length ],OCT,I
|
||||
UNATX: ;BUG INFO,[unatx desc ],OCT,D,[ length ],OCT,I
|
||||
HRLM I,0(D) ;Set SLEN
|
||||
MOVSI A,%UNTD"OWN+%UNTD"STF+%UNTD"ENF
|
||||
IORM A,1(D) ;Set flags
|
||||
|
||||
@@ -799,7 +799,9 @@ IPQCLS: HLRZ I,(R) ; Get IQ idx
|
||||
IPQCL1: MOVEI Q,IPUQHD(I)
|
||||
CALL PKQGF(PK.IP) ; Get first thing queued up
|
||||
JUMPE A,[CONO PI,NETON ; Exit if no more.
|
||||
CALRET IPOGO] ; Ensure output fired up.
|
||||
IFN IMPP, CALRET IPOGO ; Ensure output fired up.
|
||||
IFE IMPP, RET
|
||||
]
|
||||
MOVEI Q,IPOUTQ
|
||||
CALL PKQPL(PK.IP) ; Put at end of real output queue
|
||||
JRST IPQCL1
|
||||
@@ -1245,7 +1247,7 @@ IPSNI1: MOVE T,TIME ; Remember that this gateway entry was used
|
||||
|
||||
EBLK
|
||||
|
||||
; Network Interface tables. Currently only knows about IMP and CHAOS.
|
||||
; Network Interface tables. Currently knows about IMP, CHAOS and Ethernet.
|
||||
|
||||
NIFIPA: ; IP Address for network interface
|
||||
IFN IMPP, IMPUS3 ; IP address on IMP interface
|
||||
@@ -1268,7 +1270,7 @@ IFN .-NIFIPN-NNIFS, .ERR Wrong size table - NIFIPN
|
||||
NIFIPO: ; IP Output routine for network interface
|
||||
IFN IMPP, IPKSNA ; Send IP dgm to IMP output
|
||||
IFN CHAOSP, IPKSNC ; Send IP dgm to Chaos, may fragment
|
||||
IFN ETHERP, IPKSNE ; Send IP dgm to Ethernet, may fragment
|
||||
IFN ETHERP, ETHTXI ; Send IP dgm to Ethernet, may fragment
|
||||
IFN .-NIFIPO-NNIFS, .ERR Wrong size table - NIFIPO
|
||||
|
||||
;NIFNAM: ; Interface name (in case of PEEKing someday?)
|
||||
@@ -1434,13 +1436,6 @@ IPKSC9: MOVE A,J ; The PE
|
||||
|
||||
] ; IFN CHAOSP
|
||||
|
||||
IFN ETHERP,[
|
||||
|
||||
; FIXME write IPKSNE
|
||||
; IFE CHAOSP,with IPOGO
|
||||
|
||||
] ; IFN ETHERP
|
||||
|
||||
IPKSN5: MOVEI Q,IPUQHD+1 ; Put on System Output queue
|
||||
MOVE B,(Q) ; Save prev contents of header
|
||||
CALL PKQPL(PK.IP)
|
||||
|
||||
Reference in New Issue
Block a user