.. | .. |
---|
981 | 981 | } |
---|
982 | 982 | |
---|
983 | 983 | /** |
---|
| 984 | + * dpsw_fdb_dump() - Dump the content of FDB table into memory. |
---|
| 985 | + * @mc_io: Pointer to MC portal's I/O object |
---|
| 986 | + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
---|
| 987 | + * @token: Token of DPSW object |
---|
| 988 | + * @fdb_id: Forwarding Database Identifier |
---|
| 989 | + * @iova_addr: Data will be stored here as an array of struct fdb_dump_entry |
---|
| 990 | + * @iova_size: Memory size allocated at iova_addr |
---|
| 991 | + * @num_entries:Number of entries written at iova_addr |
---|
| 992 | + * |
---|
| 993 | + * Return: Completion status. '0' on Success; Error code otherwise. |
---|
| 994 | + * |
---|
| 995 | + * The memory allocated at iova_addr must be initialized with zero before |
---|
| 996 | + * command execution. If the FDB table does not fit into memory MC will stop |
---|
| 997 | + * after the memory is filled up. |
---|
| 998 | + * The struct fdb_dump_entry array must be parsed until the end of memory |
---|
| 999 | + * area or until an entry with mac_addr set to zero is found. |
---|
| 1000 | + */ |
---|
| 1001 | +int dpsw_fdb_dump(struct fsl_mc_io *mc_io, |
---|
| 1002 | + u32 cmd_flags, |
---|
| 1003 | + u16 token, |
---|
| 1004 | + u16 fdb_id, |
---|
| 1005 | + u64 iova_addr, |
---|
| 1006 | + u32 iova_size, |
---|
| 1007 | + u16 *num_entries) |
---|
| 1008 | +{ |
---|
| 1009 | + struct dpsw_cmd_fdb_dump *cmd_params; |
---|
| 1010 | + struct dpsw_rsp_fdb_dump *rsp_params; |
---|
| 1011 | + struct fsl_mc_command cmd = { 0 }; |
---|
| 1012 | + int err; |
---|
| 1013 | + |
---|
| 1014 | + /* prepare command */ |
---|
| 1015 | + cmd.header = mc_encode_cmd_header(DPSW_CMDID_FDB_DUMP, |
---|
| 1016 | + cmd_flags, |
---|
| 1017 | + token); |
---|
| 1018 | + cmd_params = (struct dpsw_cmd_fdb_dump *)cmd.params; |
---|
| 1019 | + cmd_params->fdb_id = cpu_to_le16(fdb_id); |
---|
| 1020 | + cmd_params->iova_addr = cpu_to_le64(iova_addr); |
---|
| 1021 | + cmd_params->iova_size = cpu_to_le32(iova_size); |
---|
| 1022 | + |
---|
| 1023 | + /* send command to mc */ |
---|
| 1024 | + err = mc_send_command(mc_io, &cmd); |
---|
| 1025 | + if (err) |
---|
| 1026 | + return err; |
---|
| 1027 | + |
---|
| 1028 | + rsp_params = (struct dpsw_rsp_fdb_dump *)cmd.params; |
---|
| 1029 | + *num_entries = le16_to_cpu(rsp_params->num_entries); |
---|
| 1030 | + |
---|
| 1031 | + return 0; |
---|
| 1032 | +} |
---|
| 1033 | + |
---|
| 1034 | +/** |
---|
984 | 1035 | * dpsw_fdb_remove_unicast() - removes an entry from MAC lookup table |
---|
985 | 1036 | * @mc_io: Pointer to MC portal's I/O object |
---|
986 | 1037 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
---|
.. | .. |
---|
1163 | 1214 | |
---|
1164 | 1215 | return 0; |
---|
1165 | 1216 | } |
---|
| 1217 | + |
---|
| 1218 | +/** |
---|
| 1219 | + * dpsw_if_get_port_mac_addr() |
---|
| 1220 | + * @mc_io: Pointer to MC portal's I/O object |
---|
| 1221 | + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
---|
| 1222 | + * @token: Token of DPSW object |
---|
| 1223 | + * @if_id: Interface Identifier |
---|
| 1224 | + * @mac_addr: MAC address of the physical port, if any, otherwise 0 |
---|
| 1225 | + * |
---|
| 1226 | + * Return: Completion status. '0' on Success; Error code otherwise. |
---|
| 1227 | + */ |
---|
| 1228 | +int dpsw_if_get_port_mac_addr(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, |
---|
| 1229 | + u16 if_id, u8 mac_addr[6]) |
---|
| 1230 | +{ |
---|
| 1231 | + struct dpsw_rsp_if_get_mac_addr *rsp_params; |
---|
| 1232 | + struct fsl_mc_command cmd = { 0 }; |
---|
| 1233 | + struct dpsw_cmd_if *cmd_params; |
---|
| 1234 | + int err, i; |
---|
| 1235 | + |
---|
| 1236 | + /* prepare command */ |
---|
| 1237 | + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_GET_PORT_MAC_ADDR, |
---|
| 1238 | + cmd_flags, |
---|
| 1239 | + token); |
---|
| 1240 | + cmd_params = (struct dpsw_cmd_if *)cmd.params; |
---|
| 1241 | + cmd_params->if_id = cpu_to_le16(if_id); |
---|
| 1242 | + |
---|
| 1243 | + /* send command to mc*/ |
---|
| 1244 | + err = mc_send_command(mc_io, &cmd); |
---|
| 1245 | + if (err) |
---|
| 1246 | + return err; |
---|
| 1247 | + |
---|
| 1248 | + /* retrieve response parameters */ |
---|
| 1249 | + rsp_params = (struct dpsw_rsp_if_get_mac_addr *)cmd.params; |
---|
| 1250 | + for (i = 0; i < 6; i++) |
---|
| 1251 | + mac_addr[5 - i] = rsp_params->mac_addr[i]; |
---|
| 1252 | + |
---|
| 1253 | + return 0; |
---|
| 1254 | +} |
---|
| 1255 | + |
---|
| 1256 | +/** |
---|
| 1257 | + * dpsw_if_get_primary_mac_addr() |
---|
| 1258 | + * @mc_io: Pointer to MC portal's I/O object |
---|
| 1259 | + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
---|
| 1260 | + * @token: Token of DPSW object |
---|
| 1261 | + * @if_id: Interface Identifier |
---|
| 1262 | + * @mac_addr: MAC address of the physical port, if any, otherwise 0 |
---|
| 1263 | + * |
---|
| 1264 | + * Return: Completion status. '0' on Success; Error code otherwise. |
---|
| 1265 | + */ |
---|
| 1266 | +int dpsw_if_get_primary_mac_addr(struct fsl_mc_io *mc_io, u32 cmd_flags, |
---|
| 1267 | + u16 token, u16 if_id, u8 mac_addr[6]) |
---|
| 1268 | +{ |
---|
| 1269 | + struct dpsw_rsp_if_get_mac_addr *rsp_params; |
---|
| 1270 | + struct fsl_mc_command cmd = { 0 }; |
---|
| 1271 | + struct dpsw_cmd_if *cmd_params; |
---|
| 1272 | + int err, i; |
---|
| 1273 | + |
---|
| 1274 | + /* prepare command */ |
---|
| 1275 | + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_PRIMARY_MAC_ADDR, |
---|
| 1276 | + cmd_flags, |
---|
| 1277 | + token); |
---|
| 1278 | + cmd_params = (struct dpsw_cmd_if *)cmd.params; |
---|
| 1279 | + cmd_params->if_id = cpu_to_le16(if_id); |
---|
| 1280 | + |
---|
| 1281 | + /* send command to mc*/ |
---|
| 1282 | + err = mc_send_command(mc_io, &cmd); |
---|
| 1283 | + if (err) |
---|
| 1284 | + return err; |
---|
| 1285 | + |
---|
| 1286 | + /* retrieve response parameters */ |
---|
| 1287 | + rsp_params = (struct dpsw_rsp_if_get_mac_addr *)cmd.params; |
---|
| 1288 | + for (i = 0; i < 6; i++) |
---|
| 1289 | + mac_addr[5 - i] = rsp_params->mac_addr[i]; |
---|
| 1290 | + |
---|
| 1291 | + return 0; |
---|
| 1292 | +} |
---|
| 1293 | + |
---|
| 1294 | +/** |
---|
| 1295 | + * dpsw_if_set_primary_mac_addr() |
---|
| 1296 | + * @mc_io: Pointer to MC portal's I/O object |
---|
| 1297 | + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
---|
| 1298 | + * @token: Token of DPSW object |
---|
| 1299 | + * @if_id: Interface Identifier |
---|
| 1300 | + * @mac_addr: MAC address of the physical port, if any, otherwise 0 |
---|
| 1301 | + * |
---|
| 1302 | + * Return: Completion status. '0' on Success; Error code otherwise. |
---|
| 1303 | + */ |
---|
| 1304 | +int dpsw_if_set_primary_mac_addr(struct fsl_mc_io *mc_io, u32 cmd_flags, |
---|
| 1305 | + u16 token, u16 if_id, u8 mac_addr[6]) |
---|
| 1306 | +{ |
---|
| 1307 | + struct dpsw_cmd_if_set_mac_addr *cmd_params; |
---|
| 1308 | + struct fsl_mc_command cmd = { 0 }; |
---|
| 1309 | + int i; |
---|
| 1310 | + |
---|
| 1311 | + /* prepare command */ |
---|
| 1312 | + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_PRIMARY_MAC_ADDR, |
---|
| 1313 | + cmd_flags, |
---|
| 1314 | + token); |
---|
| 1315 | + cmd_params = (struct dpsw_cmd_if_set_mac_addr *)cmd.params; |
---|
| 1316 | + cmd_params->if_id = cpu_to_le16(if_id); |
---|
| 1317 | + for (i = 0; i < 6; i++) |
---|
| 1318 | + cmd_params->mac_addr[i] = mac_addr[5 - i]; |
---|
| 1319 | + |
---|
| 1320 | + /* send command to mc*/ |
---|
| 1321 | + return mc_send_command(mc_io, &cmd); |
---|
| 1322 | +} |
---|