Skip to content
Snippets Groups Projects
Commit 135da67e authored by Aude Grabas's avatar Aude Grabas
Browse files

GBE capability: extract mac size from ccnpack

parent 57012ecd
No related branches found
No related tags found
No related merge requests found
...@@ -162,48 +162,120 @@ def centralnode_configure_comgbe(node_tangopath, npsc): ...@@ -162,48 +162,120 @@ def centralnode_configure_comgbe(node_tangopath, npsc):
logger.info("{} psc expected in the ethernet frame on {}".format(npsc, node_tangopath)) logger.info("{} psc expected in the ethernet frame on {}".format(npsc, node_tangopath))
logger.info("Configure packeter npackets to {}".format(npsc-1)) logger.info("Configure packeter npackets to {}".format(npsc-1))
for n in range(1): for n in range(1):
prx["ccnpacketh{}_npackets".format(n)] = npsc-1 prx["gigethpack{}_npackets".format(n)] = npsc-1
#maclen = npsc*4+10+20+8 #maclen = npsc*4+10+20+8
#logger.info("Configure packeter framesize (mac length) to {}".format(maclen)) #logger.info("Configure packeter framesize (mac length) to {}".format(maclen))
#prx["ccnpacketh{}_framesize".format(n)] = maclen #prx["ccnpacketh{}_framesize".format(n)] = maclen
maclen = 0x0800 maclen = 0x0800
logger.info("Configure IP protocol to {}".format(hex(maclen))) logger.info("Configure IP protocol to {}".format(hex(maclen)))
prx["ethhead{}_framesize".format(n)] = int(maclen) prx["gigethhead{}_framesize".format(n)] = int(maclen)
ipv = 4 ipv = 4
logger.info("Configure IP version to {}".format(hex(ipv))) logger.info("Configure IP version to {}".format(hex(ipv)))
prx["ethhead{}_ipv".format(n)] = ipv prx["gigethhead{}_ipv".format(n)] = ipv
ipihl = 5 ipihl = 5
logger.info("Configure IP Header Length to {}".format(hex(ipihl))) logger.info("Configure IP Header Length to {}".format(hex(ipihl)))
prx["ethhead{}_ipihl".format(n)] = ipihl prx["gigethhead{}_ipihl".format(n)] = ipihl
iplength = (npsc*4+4)+20+8 iplength = (npsc*4+4)+20+8
prx["ethhead{}_iplength".format(n)] = iplength prx["gigethhead{}_iplength".format(n)] = iplength
logger.info("IP length configured to {}".format(iplength)) logger.info("IP length configured to {}".format(iplength))
#ipdest=np.uint(0xa9fe0102) #bug found here --> not possible to set up uint32 to pyTango #ipdest=np.uint(0xa9fe0102) #bug found here --> not possible to set up uint32 to pyTango
#logger.error(ipdest) #logger.error(ipdest)
#prx["ethhead{}_ipdst".format(n)] = ipdest #prx["gigethhead{}_ipdst".format(n)] = ipdest
#logger.debug("IP dest configured to {}".format(ipdest)) #logger.debug("IP dest configured to {}".format(ipdest))
ipchksum=ipheadchk_cmp(0x4500,int(hex(iplength),16),0x8011,0xa9fe,0x0101,0xa9fe,0x0102) ipchksum=ipheadchk_cmp(0x4500,int(hex(iplength),16),0x8011,0xa9fe,0x0101,0xa9fe,0x0102)
prx["ethhead{}_ipchksum".format(n)] = int(ipchksum) prx["gigethhead{}_ipchksum".format(n)] = int(ipchksum)
logger.info("IP chksum configured to {}".format(ipchksum)) logger.info("IP chksum configured to {}".format(ipchksum))
udplength=(npsc*4+4)+8 udplength=(npsc*4+4)+8
prx["ethhead{}_udplength".format(n)] = udplength prx["gigethhead{}_udplength".format(n)] = udplength
logger.info("UDP length configured to {}".format(udplength)) logger.info("UDP length configured to {}".format(udplength))
udpport=0x75317531 udpport=0x75317531
prx["ethhead{}_udpport".format(n)] = int(udpport) prx["gigethhead{}_udpport".format(n)] = int(udpport)
logger.info("UDP ports (src&dest) configured to {}".format(hex(udpport))) logger.info("UDP ports (src&dest) configured to {}".format(hex(udpport)))
udpchksum=0x00 udpchksum=0x00
prx["ethhead{}_udpchksum".format(n)] = udpchksum prx["gigethhead{}_udpchksum".format(n)] = int(udpchksum)
logger.info("UDP ports chksum configured to {}".format(udpchksum)) logger.info("UDP ports chksum configured to {}".format(udpchksum))
logger.info("Configuration of Com GBE done on {}.".format(node_tangopath)) logger.info("Configuration of Com GBE done on {}.".format(node_tangopath))
return True return True
###################################################################################################
def cellnode_configure_ccn(node_tangopath, nbpm, npsc):
"""
Configure the ComCellNode block on a cellnode.
Automatically set the number of bpm/psc packets and MAC length.
PARAMETERS
----------
node_tangopath: str
The target fofbnode tango path, ie 'ans/dg/fofb-cellnode-c09'
nbpm:
Number of BPM allowed by the filter, hence the number of expected BPM packets.
npsc:
Number of total PSC, hence the number of expected PSC packets.
RETURN
------
success: boolean
True if configuration is a success
"""
# Get device proxy
try:
prx=tango.DeviceProxy(node_tangopath)
prx.ping()
except tango.DevFailed:
logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath))
return None
logger.debug("{} bpm allowed in the ethernet frame on {}".format(nbpm, node_tangopath))
logger.debug("{} psc expected in the ethernet frame on {}".format(npsc, node_tangopath))
maclen = 10*nbpm+10
logger.debug("Configure packeter framesize (mac length) to {}".format(maclen))
prx["ccnpack0_framesize"] = maclen
logger.debug("Configure packeter npackets to {}".format(nbpm-1))
prx["ccnpack0_npackets"] = nbpm-1
maclen = npsc*6+10
logger.debug("Configure unpacketer framesize (mac length) to {}".format(maclen))
prx["ccnunpack0_framesize"] = maclen
logger.info("Configuration of CCN done on {}.".format(node_tangopath))
return True
# Get device proxy
try:
prx=tango.DeviceProxy(node_tangopath)
prx.ping()
except tango.DevFailed:
logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath))
return None
logger.debug("{} bpm allowed in the ethernet frame on {}".format(nbpm, node_tangopath))
logger.debug("{} psc expected in the ethernet frame on {}".format(npsc, node_tangopath))
maclen = 10*nbpm+10
logger.debug("Configure packeter framesize (mac length) to {}".format(maclen))
prx["ccnpack0_framesize"] = maclen
logger.debug("Configure packeter npackets to {}".format(nbpm-1))
prx["ccnpack0_npackets"] = nbpm-1
maclen = npsc*6+10
logger.debug("Configure unpacketer framesize (mac length) to {}".format(maclen))
prx["ccnunpack0_framesize"] = maclen
logger.info("Configuration of CCN done on {}.".format(node_tangopath))
return True
################################################################################################### ###################################################################################################
...@@ -257,8 +329,9 @@ def cellnode_configure_ccn(node_tangopath, nbpm, npsc): ...@@ -257,8 +329,9 @@ def cellnode_configure_ccn(node_tangopath, nbpm, npsc):
logger.info("Configuration of CCN done on {}.".format(node_tangopath)) logger.info("Configuration of CCN done on {}.".format(node_tangopath))
return True return True
@trycatch_tango_devfailed @trycatch_tango_devfailed
def centralnode_configure_ccn_w_gbe(node_tangopath, nbpm, npsc): def centralnode_configure_ccn(node_tangopath, nbpm, npsc):
""" """
Configure the ComCellNode block on the centralnode. Configure the ComCellNode block on the centralnode.
Automatically set the number of bpm/psc packets and MAC length. Automatically set the number of bpm/psc packets and MAC length.
...@@ -286,6 +359,50 @@ def centralnode_configure_ccn_w_gbe(node_tangopath, nbpm, npsc): ...@@ -286,6 +359,50 @@ def centralnode_configure_ccn_w_gbe(node_tangopath, nbpm, npsc):
return None return None
for n in range(len(nbpm)): for n in range(len(nbpm)):
maclen = npsc*6+10
logger.debug("Configure packeter {} framesize (mac length) to {}".format(n, maclen))
prx["ccnpack{}_framesize".format(n)] = maclen
logger.debug("Configure packeter {} npackets to {}".format(n, npsc-1))
prx["ccnpack{}_npackets".format(n)] = npsc-1
maclen = 10*nbpm[n]+10
logger.debug("Configure unpacketer {} framesize (mac length) to {}".format(n, maclen))
prx["ccnunpack{}_framesize".format(n)] = maclen
logger.info("Configuration of CCN done on {}.".format(node_tangopath))
logger.info("Configuration of CCN done on {}.".format(node_tangopath))
return True
@trycatch_tango_devfailed
def centralnode_configure_ccn_w_gbe(node_tangopath, nbpm, npsc):
"""
Configure the ComCellNode block on the centralnode.
Automatically set the number of bpm/psc packets and MAC length.
PARAMETERS
----------
node_tangopath: str
The target fofbnode tango path, ie 'ans/dg/fofb-centralnode'
nbpm: list(int)
Number of BPM packet received on each interface.
npsc:
Number of total PSC, hence the number of expected PSC packets.
RETURN
------
success: boolean
True if configuration is a success
"""
# Get device proxy
try:
prx=tango.DeviceProxy(node_tangopath)
prx.ping()
except tango.DevFailed:
logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath))
return None
for n in range(4):
maclen = npsc*4+4 maclen = npsc*4+4
logger.debug("Configure packeter {} framesize (mac length) to {}".format(n, maclen)) logger.debug("Configure packeter {} framesize (mac length) to {}".format(n, maclen))
prx["ccnethhead{}_framesize".format(n)] = maclen prx["ccnethhead{}_framesize".format(n)] = maclen
......
...@@ -318,7 +318,7 @@ def reset_gbe(node_tangopath, ccnif=[]): ...@@ -318,7 +318,7 @@ def reset_gbe(node_tangopath, ccnif=[]):
logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath)) logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath))
return False return False
if len(ccnif) == 0: if len(ccnif) == 0:
ccnif = [int(a[6]) for a in prx.get_attribute_list() if "gigeth" in a if "reset" in a] ccnif = [int(a[6]) for a in prx.get_attribute_list() if "gigeth" in a if "reset" in a if not "error" in a]
logger.info("Reset GBE on {}".format(node_tangopath)) logger.info("Reset GBE on {}".format(node_tangopath))
for n in ccnif: for n in ccnif:
prx["gigeth{}_reset".format(n)] = 1 prx["gigeth{}_reset".format(n)] = 1
...@@ -357,13 +357,13 @@ def start_gbe(node_tangopath, ccnif=[]): ...@@ -357,13 +357,13 @@ def start_gbe(node_tangopath, ccnif=[]):
except tango.DevFailed: except tango.DevFailed:
logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath)) logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath))
return False return False
if len(ccnif) == 0: #if len(ccnif) == 0:
ccnif = [int(a[10]) for a in prx.get_attribute_list() if "ccnpacketh" in a if "control" in a] ccnif = [int(a[10]) for a in prx.get_attribute_list() if "gigethpack" in a if "control" in a]
reset_gbe(node_tangopath, ccnif) reset_gbe(node_tangopath, ccnif)
logger.info("Starting GBE on {}".format(node_tangopath)) logger.info("Starting GBE on {}".format(node_tangopath))
for n in ccnif: for n in ccnif:
if 'central' in node_tangopath: if 'central' in node_tangopath:
prx["ccnpacketh{}_control".format(n)] = 1 prx["gigethpack{}_control".format(n)] = 1
else: else:
pass pass
logger.info("COM GBE started on {}".format(node_tangopath)) logger.info("COM GBE started on {}".format(node_tangopath))
...@@ -395,15 +395,15 @@ def ack_gbe(node_tangopath, ccnif=[]): ...@@ -395,15 +395,15 @@ def ack_gbe(node_tangopath, ccnif=[]):
return False return False
if len(ccnif) == 0: if len(ccnif) == 0:
ccnif = [int(a[10]) for a in prx.get_attribute_list() if "ccnpacketh" in a if "control" in a] ccnif = [int(a[10]) for a in prx.get_attribute_list() if "gigethpack" in a if "control" in a]
logger.info("Ack GBE error on {}".format(node_tangopath)) logger.info("Ack GBE error on {}".format(node_tangopath))
for n in ccnif: for n in ccnif:
prx["ccnpacketh{}_reset_error".format(n)] = 1 prx["gigethpack{}_reset_error".format(n)] = 1
time.sleep(1) time.sleep(1)
for n in ccnif: for n in ccnif:
prx["ccnpacketh{}_reset_error".format(n)] = 0 prx["gigethpack{}_reset_error".format(n)] = 0
logger.info("ACK GBE error on {} done".format(node_tangopath)) logger.info("ACK GBE error on {} done".format(node_tangopath))
return True return True
...@@ -424,7 +424,6 @@ def stop_gbe(node_tangopath, ccnif=[]): ...@@ -424,7 +424,6 @@ def stop_gbe(node_tangopath, ccnif=[]):
------- -------
bool: success bool: success
""" """
try: try:
prx=tango.DeviceProxy(node_tangopath) prx=tango.DeviceProxy(node_tangopath)
prx.ping() prx.ping()
...@@ -432,11 +431,11 @@ def stop_gbe(node_tangopath, ccnif=[]): ...@@ -432,11 +431,11 @@ def stop_gbe(node_tangopath, ccnif=[]):
logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath)) logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath))
return False return False
if len(ccnif) == 0: if len(ccnif) == 0:
ccnif = [int(a[10]) for a in prx.get_attribute_list() if "ccnpacketh" in a if "control" in a] ccnif = [int(a[10]) for a in prx.get_attribute_list() if "gigethpack" in a if "control" in a]
logger.info("Stopping GBE com on {}".format(node_tangopath)) logger.info("Stopping GBE com on {}".format(node_tangopath))
for n in ccnif: for n in ccnif:
if 'central' in node_tangopath: if 'central' in node_tangopath:
prx["ccnpacketh{}_control".format(n)] = False prx["gigethpack{}_control".format(n)] = False
reset_gbe(node_tangopath,ccnif) reset_gbe(node_tangopath,ccnif)
return True return True
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment