Beispiel #1
0
def write_table(position, wr_cmp_data, wr_cmp_mask, wr_action_data):
    '''
        position: priority in table (0-31, 0 highest priority)
        wr_cmp_data: headers to look for
        wr_cmp_mask: what to mask against (1s are don't care)
        wr_action_data: headers to be applied
        wr_action_ctrl: numeric mask of fields to modify
    '''

    if type(wr_cmp_data) is not OFHeader:
        raise Exception("Must be OFHeader type")

    if type(wr_cmp_mask) is not OFHeader:
        raise Exception("Must be OFHeader type")

    if type(wr_action_data) is not OFHeader:
        raise Exception("Must be OFHeader type")

    if not (0 <= position < rd.OF_NUM_ENTRIES()):
        raise Exception("Invalid position argument")

    cmp_din = wr_cmp_mask.serialize()
    cmp_mask = wr_cmp_data.serialize()
    action_data = wr_action_data.serialize()

    for i in xrange(9):
        writeReg(rd.MATCHER_LUT_DATA_0_REG()+4*i, action_data[i])
        writeReg(rd.MATCHER_TCAM_DATA_0_REG()+4*i, cmp_din[i])
        writeReg(rd.MATCHER_TCAM_MASK_0_REG()+4*i, cmp_mask[i])

    # Dummy write to write reg for tcam push
    time.sleep(1)
    writeReg(rd.MATCHER_WRITE_REG_REG(), position)
    print [hex(x) for x in cmp_din]
Beispiel #2
0
def read_table(index):
    writeReg(rd.MATCHER_READ_REG_REG(), index)
    time.sleep(2)

    vals, vals2, vals3= [], [], []
    for j in xrange(9):
        vals.append(readReg(rd.MATCHER_LUT_DATA_0_REG()+4*j))
        vals2.append(readReg(rd.MATCHER_TCAM_DATA_0_REG()+4*j))
        vals3.append(readReg(rd.MATCHER_TCAM_MASK_0_REG()+4*j))
    print [hex(x) for x in vals]
    print [hex(x) for x in vals2]
    print [hex(x) for x in vals3]
    tot = [vals, vals2, vals3]
    for k in xrange(3):
        mydata = struct.pack("I"*9, *tot[k])
        of_h = OFHeader(mydata)

        print [(x[0], of_h.pretty.get(x[0], -1)) for x in OF_STRUCT]
Beispiel #3
0
def regwrite(reg, val):
#    if ifaceName.startswith('nf'):
        hwReg.writeReg(reg, val)
Beispiel #4
0
def regwrite(reg, val):
        hwReg.writeReg(reg, val)
Beispiel #5
0
def regwrite(reg, val):
#    if ifaceName.startswith('nf'):
        hwReg.writeReg(reg, val)
Beispiel #6
0
def regwrite(ifaceName, reg, val):
    if ifaceName.startswith('nf2c'):
        hwReg.writeReg(reg, val, ifaceName)
Beispiel #7
0
def regwrite(ifaceName, reg, val):
    if ifaceName.startswith('nf2c'):
        hwReg.writeReg(reg, val, ifaceName)