OpenWrt Forum Archive

Topic: rtl8366rb.c extend for port_ability

The content of this topic has been archived on 1 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,
inspired by the patch in Ticket #7977 I wanted an option to set speed/duplex instead of auto neogation.

In realtek.info/pdf/rtl8366_8369_datasheet_1-1.pdf on page 85 I saw a solution:
"10.3.6. 0x0011 - 0x0015: Port Advertising Ability Control Register 0-4 (PAACR0-4)"

I just wanted to test it with a little snippet, but it doesn't work like I want to (explanation after Code):

static int rtl8366rb_sw_get_port_ability(struct switch_dev *dev,
                    const struct switch_attr *attr,
                    struct switch_val *val)
{
    struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
    u32 data = 0;

    rtl8366_smi_read_reg(smi, RTL8366RB_PAACR0, &data);
    val->value.i = data;

    return 0;
}

static int rtl8366rb_sw_set_port_ability(struct switch_dev *dev,
                    const struct switch_attr *attr,
                    struct switch_val *val)
{
    struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
    u32 data;
    u32 mask;
    u32 reg;

    reg = RTL8366RB_PAACR0;
    mask = 0xFF << (0 * 4),
    data = 0b11010000 << (0 * 4);
    
    return rtl8366_smi_rmwr(smi, reg, mask, data);
}

//...

static struct switch_attr rtl8366rb_port[] = {
//...
    }, {
        .type = SWITCH_TYPE_INT,
        .name = "port_ability",
        .description = "Get/Set port_ability",
        .max = 7,
        .set = rtl8366rb_sw_set_port_ability,
        .get = rtl8366rb_sw_get_port_ability,
    },
};

(I know ... that isn't nice, I just want to get it to work before extending features.)

As you can see I set the port_ability of Port 0 (WAN) to 0b11010000 (ignoring the port number and state I set in swconfig).

It seems it is set correctly:

root@OpenWrt:/# swconfig dev rtl8366rb port 0 set port_ability 0
root@OpenWrt:/# swconfig dev rtl8366rb port 0 get port_ability
65488

But no matter what I try - i always have 1000FDx:

root@OpenWrt:/# swconfig dev rtl8366rb port 0 get link
port:0 link:up speed:1000baseT full-duplex txflow rxflow

Do you have any idea how I can get this working? Thanks, Florian.

I'm not sure, was long time ago,
but You should also read 8.14 (port property configuration) in the datasheet.
They say something about "power on strapping" and "EEPROM".
That's why i decided to write directly to the PHY registers...

regards,
Ralph

(Last edited by sagemol on 10 Jun 2012, 15:58)

Thanks, will look into that. I found no documentation 'bout they way you did it ... which solution would be the better?

I don't see any advantage in any solution.
To find the docu for the "way i did it" you'll have to look into the rtl8212_rtl8212n_rtl8211n_datasheet_1.3.pdf.


regards,
Ralph

The discussion might have continued from here.